Skip to content

Commit 441d407

Browse files
authored
Added support for WDT model only to REBASE operation (#258)
1 parent 6a30387 commit 441d407

File tree

12 files changed

+79
-43
lines changed

12 files changed

+79
-43
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public BuildCommand(String buildEngine, String contextFolder) {
4949
* @param value full path to Docker
5050
* @deprecated use --builder instead
5151
*/
52+
@Deprecated
5253
public void dockerPath(String value) {
5354
command.set(0, value);
5455
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CreateImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public CommandResponse call() throws Exception {
6868

6969
BuildCommand cmdBuilder = getInitialBuildCmd(tmpDir);
7070
// build wdt args if user passes --wdtModelPath
71-
wdtOptions.handleWdtArgs(dockerfileOptions, cmdBuilder, tmpDir);
71+
wdtOptions.handleWdtArgs(dockerfileOptions, tmpDir);
7272

7373
// resolve required patches
7474
handlePatchFiles(installerType);

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/RebaseImage.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public CommandResponse call() throws Exception {
5252
String newOracleHome = null;
5353
String newJavaHome = null;
5454
String domainHome;
55+
String modelHome;
56+
boolean modelOnly;
5557

5658
try {
5759

@@ -67,18 +69,19 @@ public CommandResponse call() throws Exception {
6769
Utils.copyResourceAsFile("/probe-env/test-update-env.sh",
6870
tmpDir + File.separator + "test-env.sh", true);
6971

72+
logger.info("IMG-0091", sourceImage);
7073
Properties baseImageProperties = Utils.getBaseImageProperties(buildEngine, sourceImage, tmpDir);
7174

7275
oldOracleHome = baseImageProperties.getProperty("ORACLE_HOME", null);
7376
oldJavaHome = baseImageProperties.getProperty("JAVA_PATH", null);
7477
domainHome = baseImageProperties.getProperty("DOMAIN_HOME", null);
75-
78+
modelHome = baseImageProperties.getProperty("WDT_MODEL_HOME", null);
79+
modelOnly = Boolean.parseBoolean(baseImageProperties.getProperty("WDT_MODEL_ONLY", null));
7680
} else {
7781
return new CommandResponse(-1, "Source Image not set");
7882
}
7983

80-
81-
if (targetImage != null && !targetImage.isEmpty()) {
84+
if (!Utils.isEmptyString(targetImage)) {
8285
logger.finer("IMG-0002", targetImage);
8386
dockerfileOptions.setTargetImage(targetImage);
8487
dockerfileOptions.setRebaseToTarget(true);
@@ -103,12 +106,22 @@ public CommandResponse call() throws Exception {
103106
return new CommandResponse(-1, Utils.getMessage("IMG-0021"));
104107
}
105108

106-
if (domainHome != null && !domainHome.isEmpty()) {
107-
dockerfileOptions.setDomainHome(domainHome);
108-
} else {
109+
if (Utils.isEmptyString(domainHome)) {
109110
return new CommandResponse(-1, Utils.getMessage("IMG-0025"));
110111
}
111112

113+
if (modelOnly) {
114+
logger.info("IMG-0090", domainHome);
115+
if (Utils.isEmptyString(modelHome)) {
116+
logger.info("IMG-0089", dockerfileOptions.wdt_model_home());
117+
}
118+
}
119+
120+
dockerfileOptions
121+
.setDomainHome(domainHome)
122+
.setWdtModelHome(modelHome)
123+
.setWdtModelOnly(modelOnly);
124+
112125
BuildCommand cmdBuilder = getInitialBuildCmd(tmpDir);
113126

114127
if (dockerfileOptions.isRebaseToNew()) {

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/UpdateImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public CommandResponse call() throws Exception {
147147
BuildCommand cmdBuilder = getInitialBuildCmd(tmpDir);
148148

149149
// build wdt args if user passes --wdtModelPath
150-
wdtOptions.handleWdtArgs(dockerfileOptions, cmdBuilder, tmpDir);
150+
wdtOptions.handleWdtArgs(dockerfileOptions, tmpDir);
151151
dockerfileOptions.setWdtCommand(wdtOperation);
152152
if (dockerfileOptions.runRcu()
153153
&& (wdtOperation == WdtOperation.UPDATE || wdtOperation == WdtOperation.DEPLOY)) {

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/WdtOptions.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.util.List;
1313

1414
import com.oracle.weblogic.imagetool.api.model.CachedFile;
15-
import com.oracle.weblogic.imagetool.builder.BuildCommand;
1615
import com.oracle.weblogic.imagetool.installer.InstallerType;
1716
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
1817
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
@@ -52,8 +51,7 @@ boolean modelOnly() {
5251
* @param tmpDir the tmp directory which is passed to docker as the build context directory
5352
* @throws IOException in case of error
5453
*/
55-
void handleWdtArgs(DockerfileOptions dockerfileOptions, BuildCommand cmdBuilder, String tmpDir)
56-
throws IOException {
54+
void handleWdtArgs(DockerfileOptions dockerfileOptions, String tmpDir) throws IOException {
5755

5856
if (!isUsingWdt()) {
5957
return;

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/DockerfileOptions.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public DockerfileOptions(String buildId) {
8686

8787
javaHome = DEFAULT_JAVA_HOME;
8888
oracleHome = DEFAULT_ORACLE_HOME;
89-
domainHome = DEFAULT_DOMAIN_HOME;
9089
invLoc = DEFAULT_INV_LOC;
9190
oraInvDir = DEFAULT_ORAINV_DIR;
9291

@@ -162,6 +161,7 @@ public void setGroupId(String value) {
162161
*
163162
* @return the image name
164163
*/
164+
@SuppressWarnings("unused")
165165
public String baseImage() {
166166
return baseImageName;
167167
}
@@ -171,6 +171,7 @@ public String baseImage() {
171171
*
172172
* @return this DockerfileOptions object
173173
*/
174+
@SuppressWarnings("unused")
174175
public DockerfileOptions setBaseImage(String value) {
175176
baseImageName = value;
176177
return this;
@@ -181,6 +182,7 @@ public DockerfileOptions setBaseImage(String value) {
181182
*
182183
* @return the image name
183184
*/
185+
@SuppressWarnings("unused")
184186
public String sourceImage() {
185187
return sourceImage;
186188
}
@@ -200,6 +202,7 @@ public DockerfileOptions setSourceImage(String value) {
200202
*
201203
* @return the image name
202204
*/
205+
@SuppressWarnings("unused")
203206
public String targetImage() {
204207
return targetImage;
205208
}
@@ -220,7 +223,7 @@ public DockerfileOptions setTargetImage(String value) {
220223
* @return this DockerfileOptions object
221224
*/
222225
public DockerfileOptions setWdtModelHome(String value) {
223-
if (value != null) {
226+
if (!Utils.isEmptyString(value)) {
224227
wdtModelHome = value;
225228
}
226229
return this;
@@ -231,6 +234,7 @@ public DockerfileOptions setWdtModelHome(String value) {
231234
*
232235
* @return true or false
233236
*/
237+
@SuppressWarnings("unused")
234238
public boolean isRebaseToTarget() {
235239
return isRebaseToTarget;
236240
}
@@ -249,6 +253,7 @@ public void setRebaseToTarget(boolean rebaseToTarget) {
249253
*
250254
* @return true of false
251255
*/
256+
@SuppressWarnings("unused")
252257
public boolean isRebaseToNew() {
253258
return isRebaseToNew;
254259
}
@@ -323,9 +328,17 @@ public String orainv_dir() {
323328
return oraInvDir;
324329
}
325330

331+
/**
332+
* Used by Dockerfile template to get the domain home directory.
333+
* @return the string value of the domain home path
334+
*/
326335
@SuppressWarnings("unused")
327336
public String domain_home() {
328-
return domainHome;
337+
if (domainHome != null) {
338+
return domainHome;
339+
} else {
340+
return DEFAULT_DOMAIN_HOME;
341+
}
329342
}
330343

331344
@SuppressWarnings("unused")
@@ -413,11 +426,7 @@ public void setOraInvDir(String value) {
413426
* @param value the full path to the domain directory
414427
*/
415428
public DockerfileOptions setDomainHome(String value) {
416-
if (value != null) {
417-
domainHome = value;
418-
} else {
419-
domainHome = DEFAULT_DOMAIN_HOME;
420-
}
429+
domainHome = value;
421430
return this;
422431
}
423432

@@ -450,6 +459,7 @@ public void disableJavaInstall(String javaHome) {
450459
*
451460
* @return true if Java should be installed.
452461
*/
462+
@SuppressWarnings("unused")
453463
public boolean installJava() {
454464
return !skipJavaInstall;
455465
}
@@ -562,6 +572,7 @@ public DockerfileOptions setWdtModels(List<String> value) {
562572
*
563573
* @return true if invLoc is not equal to the default location
564574
*/
575+
@SuppressWarnings("unused")
565576
public boolean isCustomInventoryLoc() {
566577
return !invLoc.equals(DEFAULT_INV_LOC);
567578
}
@@ -672,7 +683,7 @@ public DockerfileOptions setWdtEnabled() {
672683
}
673684

674685
/**
675-
* Referenced by Dockerfile template, provides location where installers should write their temporary files.
686+
* Referenced by Dockerfile template, location in the image where the builder should write temporary files.
676687
*
677688
* @return the full path to the temporary directory that should be used.
678689
*/
@@ -681,16 +692,6 @@ public String tempDir() {
681692
return tempDirectory;
682693
}
683694

684-
/**
685-
* The location where installers should write their temporary files.
686-
*
687-
* @param value the full path to the temporary directory that should be used.
688-
*/
689-
public void setTempDirectory(String value) {
690-
691-
tempDirectory = value;
692-
}
693-
694695
/**
695696
* Referenced by Dockerfile template, provides the command to run for WDT. The default is createDomain.sh.
696697
*

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Utils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ public static boolean validatePatchIds(List<String> patches, boolean rigid) {
631631
return false;
632632
}
633633
}
634-
635634
}
636635

637636
return true;
@@ -645,7 +644,7 @@ public static boolean validatePatchIds(List<String> patches, boolean rigid) {
645644
* @param options Dockerfile options to use for the build (holds the Oracle Home argument)
646645
*/
647646
public static void setOracleHome(List<Path> responseFiles, DockerfileOptions options) throws IOException {
648-
if (responseFiles == null || responseFiles.size() < 1) {
647+
if (responseFiles == null || responseFiles.isEmpty()) {
649648
return;
650649
}
651650
Path installerResponseFile = responseFiles.get(0);

imagetool/src/main/resources/ImageTool.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,7 @@ IMG-0084=No recommended patches found for {0}
8686
IMG-0085=The recommended ADR patch was skipped for the WLS installer, use --patch {0} to apply this patch
8787
IMG-0086=Failed to find patch number [[brightred: {0}]] on Oracle servers, verify the patch number is correct using My Oracle Support.
8888
IMG-0087=The Oracle Home directory in --fromImage={0} has an owner and group of {1}:{2}. You must update the image with the same user and group setting from when it was created. Example: --chown={1}:{2}
89+
IMG-0089=WDT_MODEL_HOME was not set in the source image, using default model location: {0}
90+
IMG-0090=Rebasing WDT models. A domain was not found in the source image at {0}
91+
IMG-0091=Reading settings from the source image {0}
8992
IMG-0088=Build command failed with error: {0}

imagetool/src/main/resources/docker-files/Create_Image.mustache

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,14 @@ RUN cd {{{tempDir}}}/opatch \
127127
{{#isPatchingEnabled}}
128128
{{^strictPatchOrdering}}
129129
# Apply all patches provided at the same time
130-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
130+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -nonrollbackable -phBaseDir {{{tempDir}}}/patches \
131131
&& test $? -eq 0 \
132-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
133-
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
132+
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
134133
{{/strictPatchOrdering}}
135134
{{#strictPatchOrdering}}
136135
# Apply one patch at a time in the order they were specified
137136
{{#patches}}
138-
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} {{{tempDir}}}/patches/{{{.}}}
137+
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} -nonrollbackable {{{tempDir}}}/patches/{{{.}}}
139138
{{/patches}}
140139
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
141140
{{/strictPatchOrdering}}
@@ -222,7 +221,10 @@ ENV ORACLE_HOME={{{oracle_home}}} \
222221
{{/installJava}}
223222
{{#isWdtEnabled}}
224223
DOMAIN_HOME={{{domain_home}}} \
225-
{{/isWdtEnabled}}
224+
{{#modelOnly}}
225+
WDT_MODEL_HOME={{{wdt_model_home}}} \
226+
{{/modelOnly}}
227+
{{/isWdtEnabled}}
226228
PATH=${PATH}:{{{java_home}}}/bin:{{{oracle_home}}}/oracle_common/common/bin:{{{oracle_home}}}/wlserver/common/bin:{{{oracle_home}}}{{#isWdtEnabled}}:${{{domain_home}}}/bin{{/isWdtEnabled}}
227229

228230
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"

imagetool/src/main/resources/docker-files/Rebase_Image.mustache

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
141141
{{#isPatchingEnabled}}
142142
{{^strictPatchOrdering}}
143143
# Apply all patches provided at the same time
144-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
144+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -nonrollbackable -phBaseDir {{{tempDir}}}/patches \
145145
&& test $? -eq 0 \
146146
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
147147
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
148148
{{/strictPatchOrdering}}
149149
{{#strictPatchOrdering}}
150150
# Apply one patch at a time in the order they were specified
151151
{{#patches}}
152-
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} {{{tempDir}}}/patches/{{{.}}}
152+
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} -nonrollbackable {{{tempDir}}}/patches/{{{.}}}
153153
{{/patches}}
154154
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
155155
{{/strictPatchOrdering}}
@@ -185,7 +185,16 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
185185

186186
USER {{userid}}
187187
RUN mkdir -p {{domain_home}}
188-
COPY --from=source_image --chown={{userid}}:{{groupid}} {{domain_home}} {{domain_home}}/
188+
{{^modelOnly}}
189+
COPY --from=source_image --chown={{userid}}:{{groupid}} {{domain_home}} {{domain_home}}/
190+
{{/modelOnly}}
191+
{{#modelOnly}}
192+
COPY --from=source_image --chown={{userid}}:{{groupid}} {{{wdt_home}}} {{{wdt_home}}}/
193+
{{#isWdtModelHomeOutsideWdtHome}}
194+
COPY --from=wdt_build --chown={{userid}}:{{groupid}} {{wdt_model_home}} {{wdt_model_home}}/
195+
{{/isWdtModelHomeOutsideWdtHome}}
196+
{{/modelOnly}}
197+
189198
RUN chmod g+w {{{domain_home}}}
190199

191200
WORKDIR {{{work_dir}}}

0 commit comments

Comments
 (0)