Skip to content

Commit 59d1eaf

Browse files
authored
Enhance Update operation with additional WDT operations (#64)
* Added WDT updateDomain option for imagetool update operation * java_home is not required on command line if JAVA_HOME is set in ENV * added support for WDT deployApps
1 parent 0979f3e commit 59d1eaf

File tree

7 files changed

+82
-6
lines changed

7 files changed

+82
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ The Image Tool provides three functions within the main script:
1414
- [Create Image](site/create-image.md) - The `create` command creates a new Docker image and installs the requested
1515
Java and WebLogic software. Additionally, you can create a WebLogic domain in the image at the same time.
1616
- [Update Image](site/update-image.md) - The `update` command creates a new Docker image by applying WebLogic patches
17-
to an existing image. Additionally, you can create a WebLogic domain if one did not exist previously.
17+
to an existing image. Additionally, you can create a WebLogic domain if one did not exist previously, update an
18+
an existing domain, or deploy an application.
1819
- [Cache](site/cache.md) - The Image Tool maintains metadata on the local file system for patches and installers.
1920
The `cache` command can be used to manipulate the local metadata.
2021

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.oracle.weblogic.imagetool.util.Constants;
2424
import com.oracle.weblogic.imagetool.util.Utils;
2525
import com.oracle.weblogic.imagetool.util.ValidationResult;
26+
import com.oracle.weblogic.imagetool.util.WdtOperation;
2627
import picocli.CommandLine.Command;
2728
import picocli.CommandLine.Option;
2829

@@ -170,6 +171,7 @@ public CommandResponse call() throws Exception {
170171

171172
// build wdt args if user passes --wdtModelPath
172173
cmdBuilder.addAll(handleWdtArgsIfRequired(tmpDir));
174+
dockerfileOptions.setWdtCommand(wdtOperation);
173175

174176
// resolve required patches
175177
cmdBuilder.addAll(handlePatchFiles(tmpDir, tmpPatchesDir));
@@ -219,5 +221,12 @@ List<String> handlePatchFiles(String tmpDir, Path tmpPatchesDir) throws Exceptio
219221
)
220222
private String opatchBugNumber;
221223

224+
@Option(
225+
names = {"--wdtOperation"},
226+
description = "Create a new domain, or update an existing domain. Default: ${DEFAULT-VALUE}. "
227+
+ "Supported values: ${COMPLETION-CANDIDATES}"
228+
)
229+
private WdtOperation wdtOperation = WdtOperation.CREATE;
230+
222231
private boolean opatchRequired = false;
223232
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class DockerfileOptions {
2727
private String tempDirectory;
2828
private String baseImageName;
2929
private ArrayList<String> wdtModelList;
30+
private WdtOperation wdtOperation;
3031

3132
/**
3233
* Options to be used with the Mustache template.
@@ -48,6 +49,8 @@ public DockerfileOptions() {
4849
tempDirectory = "/tmp/delme";
4950

5051
baseImageName = "oraclelinux:7-slim";
52+
53+
wdtOperation = WdtOperation.CREATE;
5154
}
5255

5356
/**
@@ -296,4 +299,22 @@ public void setTempDirectory(String value) {
296299

297300
tempDirectory = value;
298301
}
302+
303+
/**
304+
* Referenced by Dockerfile template, provides the command to run for WDT. The default is createDomain.sh.
305+
*
306+
* @return the name of the WDT script file.
307+
*/
308+
public String wdtCommand() {
309+
return wdtOperation.getScript();
310+
}
311+
312+
/**
313+
* Set the desired WDT Operation to use during update.
314+
*
315+
* @param value CREATE or UPDATE.
316+
*/
317+
public void setWdtCommand(WdtOperation value) {
318+
wdtOperation = value;
319+
}
299320
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.util;
5+
6+
/**
7+
* Command types for WebLogic Deploy Tooling.
8+
* See GitHub project - https://github.com/oracle/weblogic-deploy-tooling
9+
*/
10+
public enum WdtOperation {
11+
12+
CREATE("createDomain.sh"),
13+
UPDATE("updateDomain.sh"),
14+
DEPLOY("deployApps.sh");
15+
16+
WdtOperation(String script) {
17+
this.script = script;
18+
}
19+
20+
private String script;
21+
22+
/**
23+
* Get the WDT script to run that maps to this WDT operation.
24+
* @return the Unix shell script name for the WDT command.
25+
*/
26+
public String getScript() {
27+
return script;
28+
}
29+
30+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ RUN unzip -q {{{tmpDir}}}/$WLS_PKG -d {{{tmpDir}}} \
153153
&& cd {{{wdt_home}}}/bin \
154154
&& {{{wdt_home}}}/bin/createDomain.sh \
155155
-oracle_home {{{oracle_home}}} \
156-
-java_home {{{java_home}}} \
157156
-domain_home ${DOMAIN_HOME} \
158157
-domain_type ${DOMAIN_TYPE} \
159158
$RCU_RUN_OPT \

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@
5757
&& if [ -n "${RCU_RUN_FLAG}" ]; then RCU_RUN_OPT="-run_rcu"; fi \
5858
&& cd {{{wdt_home}}}/bin \
5959
&& chmod u+x ./*.sh \
60-
&& ./createDomain.sh \
60+
&& ./{{wdtCommand}} \
6161
-oracle_home {{{oracle_home}}} \
62-
-java_home {{{java_home}}} \
6362
-domain_home ${DOMAIN_HOME} \
6463
-domain_type ${DOMAIN_TYPE} \
6564
$RCU_RUN_OPT \

site/update-image.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# Update Image
22

3-
Use the `update` command to apply patches to an existing WebLogic Docker image. The required options for the command
4-
are marked with an asterisk (*). The password can be provided in one of the three ways:
3+
After you have created a Docker image with the Image Tool, you may want to change it from time to time. The `update`
4+
command should be used to update these existing Docker images created with the Image Tool. For example, you may want to:
5+
* Apply a WebLogic patch
6+
* Apply the latest PSU from Oracle
7+
* Create a new WebLogic domain (if one did not already exist)
8+
* Deploy a new application to an existing domain
9+
* Modify the domain configuration (add a data source, change a port number, ...)
10+
11+
The required options for the `update` command are marked with an asterisk (*), below.
12+
**NOTE:** The password can be provided in one of the three ways:
513

614
* Plain text
715
* Environment variable
@@ -47,6 +55,9 @@ Update WebLogic docker image with selected patches
4755
RestrictedJRF
4856
--wdtModel=<wdtModelPath>
4957
path to the WDT model file that defines the Domain to create
58+
--wdtOperation=<wdtOperation>
59+
Create a new domain, or update an existing domain. Default:
60+
CREATE. Supported values: CREATE, UPDATE, DEPLOY
5061
--wdtRunRCU instruct WDT to run RCU when creating the Domain
5162
--wdtVariables=<wdtVariablesPath>
5263
path to the WDT variables file for use with the WDT model
@@ -76,5 +87,11 @@ installer is accessed from the cache with key wdt_1.1.1. The model and archive
7687
imagetool update --fromImage wls:12.2.1.3.0 --tag mydomain:1 --wdtArchive ./wdt/my_domain.zip --wdtModel ./wdt/my_domain.yaml --wdtVersion 1.1.1
7788
```
7889
90+
- Use `deployApps` from WDT to deploy a new application, the WLS Metrics Exporter. The model and archive to use are
91+
located in a subfolder named `wdt`.
92+
```
93+
imagetool update --tag mydomain:2 --fromImage mydomain:1 --wdtOperation deploy --wdtArchive ./wdt/exporter_archive.zip --wdtModel ./wdt/exporter_model.yaml --wdtVersion 1.1.1
94+
```
95+
7996
## Copyright
8097
Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.

0 commit comments

Comments
 (0)