Skip to content

Commit 1cb3848

Browse files
authored
Allow Model in Image use case (#65)
* added support for model in image - adds WDT and artifacts to image but does not create domain * cleanup permissions and usage of variable braces * set docker workdir to oracle home or domain home based on options selected
1 parent 1c6abdc commit 1cb3848

File tree

8 files changed

+395
-236
lines changed

8 files changed

+395
-236
lines changed

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
@@ -119,7 +119,7 @@ public CommandResponse call() throws Exception {
119119
// add directory to pass the context
120120
cmdBuilder.add(tmpDir);
121121
logger.info("docker cmd = " + String.join(" ", cmdBuilder));
122-
Utils.runDockerCommand(isCLIMode, cmdBuilder, dockerLog);
122+
Utils.runDockerCommand(isCliMode, cmdBuilder, dockerLog);
123123
} catch (Exception ex) {
124124
return new CommandResponse(-1, ex.getMessage());
125125
} finally {

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ public abstract class ImageOperation implements Callable<CommandResponse> {
4646
protected DockerfileOptions dockerfileOptions;
4747
protected CacheStore cacheStore = new CacheStoreFactory().get();
4848
private String nonProxyHosts = null;
49-
boolean isCLIMode;
49+
boolean isCliMode;
5050
String password;
5151

5252
ImageOperation() {
5353
dockerfileOptions = new DockerfileOptions();
5454
}
5555

56-
ImageOperation(boolean isCLIMode) {
56+
ImageOperation(boolean isCliMode) {
5757
this();
58-
this.isCLIMode = isCLIMode;
58+
this.isCliMode = isCliMode;
5959
}
6060

6161
@Override
@@ -136,8 +136,6 @@ List<String> handlePatchFiles(String tmpDir, Path tmpPatchesDir) throws Exceptio
136136
}
137137
}
138138
if (!patchLocations.isEmpty()) {
139-
retVal.add(Constants.BUILD_ARG);
140-
retVal.add("PATCHDIR=" + Paths.get(tmpDir).relativize(tmpPatchesDir).toString());
141139
dockerfileOptions.setPatchingEnabled();
142140
}
143141
logger.exiting(retVal.size());
@@ -193,7 +191,7 @@ public Path createPatchesTempDirectory(String tmpDir) throws IOException {
193191
return tmpPatchesDir;
194192
}
195193

196-
void handleProxyUrls() throws IOException {
194+
private void handleProxyUrls() throws IOException {
197195
httpProxyUrl = Utils.findProxyUrl(httpProxyUrl, Constants.HTTP);
198196
httpsProxyUrl = Utils.findProxyUrl(httpsProxyUrl, Constants.HTTPS);
199197
nonProxyHosts = Utils.findProxyUrl(nonProxyHosts, "none");
@@ -317,9 +315,12 @@ private List<String> getWdtRequiredBuildArgs(Path wdtVariablesPath) throws IOExc
317315
* @throws IOException in case of error
318316
*/
319317
protected List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
320-
logger.finer("Entering CreateImage.handleWdtArgsIfRequired: " + tmpDir);
318+
logger.entering(tmpDir);
319+
321320
List<String> retVal = new LinkedList<>();
322321
if (wdtModelPath != null) {
322+
dockerfileOptions.setWdtEnabled();
323+
dockerfileOptions.setWdtModelOnly(wdtModelOnly);
323324
String[] modelFiles = wdtModelPath.toString().split(",");
324325
List<String> modelList = new ArrayList<>();
325326

@@ -335,34 +336,28 @@ protected List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException
335336
}
336337
dockerfileOptions.setWdtModels(modelList);
337338

339+
dockerfileOptions.setWdtDomainType(wdtDomainType);
338340
if (wdtDomainType != DomainType.WLS) {
339341
if (installerType != WLSInstallerType.FMW) {
340342
throw new IOException("FMW installer is required for JRF domain");
341343
}
342-
retVal.add(Constants.BUILD_ARG);
343-
retVal.add("DOMAIN_TYPE=" + wdtDomainType);
344344
if (runRcu) {
345345
retVal.add(Constants.BUILD_ARG);
346346
retVal.add("RCU_RUN_FLAG=" + "-run_rcu");
347347
}
348348
}
349-
dockerfileOptions.setWdtEnabled();
350349

351350
if (wdtArchivePath != null && Files.isRegularFile(wdtArchivePath)) {
352351
String wdtArchiveFilename = wdtArchivePath.getFileName().toString();
353352
Files.copy(wdtArchivePath, Paths.get(tmpDir, wdtArchiveFilename));
354-
retVal.add(Constants.BUILD_ARG);
355-
retVal.add("WDT_ARCHIVE=" + wdtArchiveFilename);
356-
}
357-
if (wdtDomainHome != null) {
358-
retVal.add(Constants.BUILD_ARG);
359-
retVal.add("DOMAIN_HOME=" + wdtDomainHome);
353+
//Until WDT supports multiple archives, take single file argument from CLI and convert to list
354+
List<String> archives = new ArrayList<>();
355+
archives.add(wdtArchiveFilename);
356+
dockerfileOptions.setWdtArchives(archives);
360357
}
358+
dockerfileOptions.setDomainHome(wdtDomainHome);
361359

362-
if (wdtJavaOptions != null) {
363-
retVal.add(Constants.BUILD_ARG);
364-
retVal.add("WLSDEPLOY_PROPERTIES=" + wdtJavaOptions);
365-
}
360+
dockerfileOptions.setJavaOptions(wdtJavaOptions);
366361

367362
if (wdtVariablesPath != null && Files.isRegularFile(wdtVariablesPath)) {
368363
String wdtVariableFilename = wdtVariablesPath.getFileName().toString();
@@ -372,7 +367,7 @@ protected List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException
372367
retVal.addAll(getWdtRequiredBuildArgs(wdtVariablesPath));
373368
}
374369
}
375-
logger.finer("Exiting CreateImage.handleWdtArgsIfRequired: ");
370+
logger.exiting();
376371
return retVal;
377372
}
378373

@@ -561,6 +556,14 @@ private void addWdtUrl(String wdtKey) throws Exception {
561556
)
562557
private String wdtJavaOptions;
563558

559+
560+
@Option(
561+
names = {"--wdtModelOnly"},
562+
description = "Install WDT and copy the models to the image, but do not create the domain. "
563+
+ "Default: ${DEFAULT-VALUE}."
564+
)
565+
private boolean wdtModelOnly = false;
566+
564567
@Unmatched
565568
List<String> unmatchedOptions;
566569
}

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
@@ -183,7 +183,7 @@ public CommandResponse call() throws Exception {
183183
cmdBuilder.add(tmpDir);
184184

185185
logger.info("docker cmd = " + String.join(" ", cmdBuilder));
186-
Utils.runDockerCommand(isCLIMode, cmdBuilder, dockerLog);
186+
Utils.runDockerCommand(isCliMode, cmdBuilder, dockerLog);
187187

188188
} catch (Exception ex) {
189189
return new CommandResponse(-1, ex.getMessage());

0 commit comments

Comments
 (0)