Skip to content

Commit 1dda838

Browse files
authored
Tutorial (#13)
* Fix cli fails without any message when invalid command is specified and add quick start guide * minor edits * minor edits * minor edits * minor edits * Remove extraneous system out * added some notes on setting up cache store first * spelling * add env variable for docker build to override working dir * update and add wdt case * format changes * update wdt download links * change sample cache directories * Add notes for final image installation and owner * add comment for loging.properties * update wdt use case * rename WebLogic Deploying Tool to WebLogic Deploy Tool * add parameter file section * There are various fixes on this commit: 1. Add wdtDomainHome as build argument passing from imagetool 2. Remove unnecessary variable DOMAIN_NAME 3. Remove all start*.sh inherited from wls docker-images project * minor text edit * change multi layer build * change to use force rm only. Actually it doesn't matter, there are couple of dangling images left over. Added instruction in quickstart showing how to clean it up. * update addPatch command * update addPatch with comment * update documentation * cleanup main README * first edit after review * minor doc edit and fix non wdt docker build
1 parent 1c860b6 commit 1dda838

File tree

10 files changed

+355
-50
lines changed

10 files changed

+355
-50
lines changed

README.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,12 @@ The Image Tool provides three functions within the main script:
2929

3030
- Build the project (`mvn clean package`), to create the ZIP installer in ./imagetool/target.
3131
- Unzip the release ZIP file to a desired location.
32-
- If running an OS with bash, run `cd your_unzipped_location/bin` and `source setup.sh`.
33-
- On Windows, set up with `imagetool.cmd` or the `imagetool.bat` script:
34-
```cmd
35-
@ECHO OFF
36-
java -cp "your_unzipped_folder/lib" com.oracle.weblogic.imagetool.cli.CLIDriver %*
37-
```
38-
39-
## Help Command
40-
- After completing the [Setup](#Setup) steps, execute `imagetool help` to show the help screen.
41-
- You can execute the JAR directly using the command `java -cp "your_unzipped_folder/lib" com.oracle.weblogic.imagetool.cli.CLIDriver help`.
42-
43-
## Simple Example
44-
Let's give this a try!
45-
- Get the installers from Oracle e-Delivery.
46-
- Add those installers to the Image Tool file cache.
47-
- Assuming Docker is installed, run `imagetool create`!
48-
```bash
49-
unzip imagetool-0.1.zip
50-
cd imagetool-0.1/bin
51-
source setup.sh
52-
imagetool cache addInstaller --type jdk --version 8u202 --path /tmp/jdk-8u202-linux-x64.tar.gz
53-
imagetool cache addInstaller --type wls --version 12.2.1.3.0 --path /tmp/fmw_12.2.1.3.0_wls_Disk1_1of1.zip
54-
imagetool create --tag sample:wls
55-
```
32+
- `cd your_unzipped_location/bin` and `source setup.sh`.
33+
- Run `imagetool help` to show the help screen.
34+
35+
## Quick Start
36+
37+
[Image Tool Quick Start Guide](site/quickstart.md)
5638

5739
## Copyright
5840
Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.

imagetool/src/main/bin/logging.properties

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
#
2+
# This is a standard java util logging.properties, documentation can be found in
3+
# https://docs.oracle.com/javase/8/docs/technotes/guides/logging/overview.html#a1.8
4+
#
5+
6+
#
7+
# Default handler is console only, to enable file logging, switch out the comments below or customize your own
8+
#
19
handlers=java.util.logging.ConsoleHandler
210
#handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
311

4-
# Enable as needed
12+
#
13+
# Default level for everything is INFO, you can override the level in each logger or raise the default level for all
14+
# loggers. Note: if you set .LEVEL=ALL, it will enable everything from every loggers used by the tool including other
15+
# any packages used by the tool.
16+
#
17+
518
com.oracle.weblogic.imagetool.level=INFO
619
#com.oracle.weblogic.imagetool.cli.menu.CreateImage.level = FINEST
720
#com.oracle.weblogic.imagetool.cli.menu.UpdateImage.level = FINEST
@@ -13,7 +26,8 @@ com.oracle.weblogic.imagetool.level=INFO
1326
#com.oracle.weblogic.imagetool.util.Utils.level = FINEST
1427

1528
#
16-
# Change log file location and handlers logging level as needed
29+
# Change log file location and handlers logging level as needed. Note the default level for FileHandler is OFF
30+
# and ConsoleHandler is INFO
1731
#
1832
java.util.logging.FileHandler.pattern=tool.log
1933
java.util.logging.FileHandler.count=1

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/WLSCommandLine.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ public static <C extends Callable<T>, T> T call(C callable, PrintStream out, Pri
3434
cmd.setToggleBooleanFlags(false);
3535
cmd.setUnmatchedArgumentsAllowed(false);
3636
//cmd.registerConverter(CacheStore.class, x -> new CacheStoreFactory().getCacheStore(x));
37-
3837
List<Object> results = cmd.parseWithHandlers(new CommandLine.RunLast().useOut(out).useAnsi(ansi),
3938
new CommandLine.DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args);
4039
@SuppressWarnings("unchecked") T result = results == null || results.isEmpty() ? null : (T) results.get(0);
40+
if (result == null) {
41+
CommandLine.usage(callable, System.out);
42+
// System.exit(-1);
43+
}
4144
return result;
4245
}
4346
}

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ public CommandResponse call() throws Exception {
6565
}
6666

6767
List<String> cmdBuilder = getInitialBuildCmd();
68-
// create a tmp directory for user.
69-
// using user home as base to avoid running out of space in tmp
70-
tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("user.home")),
68+
tmpDir = Files.createTempDirectory(Paths.get(Utils.getBuildWorkingDir()),
7169
"wlsimgbuilder_temp", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")));
7270
String tmpDirPath = tmpDir.toAbsolutePath().toString();
7371
logger.info("tmp directory used for build context: " + tmpDirPath);
@@ -82,9 +80,9 @@ public CommandResponse call() throws Exception {
8280
cmdBuilder.add(Constants.BUILD_ARG);
8381
cmdBuilder.add("BASE_IMAGE=" + fromImage);
8482

85-
tmpDir2 = Files.createTempDirectory(Paths.get(System.getProperty("user.home")),
83+
tmpDir2 = Files.createTempDirectory(Paths.get(Utils.getBuildWorkingDir()),
8684
"wlsimgbuilder_temp", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")));
87-
logger.info("tmp directory in user.home for docker run: " + tmpDir2);
85+
logger.info("tmp directory for docker run: " + tmpDir2);
8886

8987
Utils.copyResourceAsFile("/probe-env/test-create-env.sh",
9088
tmpDir2.toAbsolutePath().toString() + File.separator + "test-env.sh", true);
@@ -221,6 +219,12 @@ private List<String> handleWDTArgsIfRequired(Path tmpDir) throws IOException {
221219
retVal.add("WDT_ARCHIVE=" + tmpDir.relativize(targetLink).toString());
222220
}
223221

222+
if (wdtDomainHome != null) {
223+
retVal.add(Constants.BUILD_ARG);
224+
retVal.add("DOMAIN_HOME=" + wdtDomainHome);
225+
}
226+
227+
224228
if (wdtVariablesPath != null && Files.isRegularFile(wdtVariablesPath)) {
225229
targetLink = Files.copy(wdtVariablesPath, Paths.get(tmpDirPath,
226230
wdtVariablesPath.getFileName().toString())
@@ -396,4 +400,14 @@ private void copyResponseFilesToDir(String dirPath) throws IOException {
396400
description = "whether to run rcu to create the required database schemas"
397401
)
398402
private boolean rcu_run_flag = false;
403+
404+
405+
@Option(
406+
names = {"--wdtDomainHome"},
407+
description = "pass to the -domain_home for wdt",
408+
defaultValue = "/u01/domains/base_domain"
409+
)
410+
private Path wdtDomainHome;
411+
412+
399413
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ List<String> getInitialBuildCmd() {
139139

140140
logger.finer("Entering ImageOperation.getInitialBuildCmd");
141141
List<String> cmdBuilder = Stream.of("docker", "build",
142-
"--force-rm", "--rm=true", "--no-cache").collect(Collectors.toList());
142+
"--force-rm=true", "--no-cache").collect(Collectors.toList());
143143

144144
cmdBuilder.add("--tag");
145145
cmdBuilder.add(imageTag);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ public CommandResponse call() throws Exception {
7070
cmdBuilder.add("BASE_IMAGE=" + fromImage);
7171
}
7272

73-
tmpDir2 = Files.createTempDirectory(Paths.get(System.getProperty("user.home")), "wlsimgbuilder_temp",
73+
tmpDir2 = Files.createTempDirectory(Paths.get(Utils.getBuildWorkingDir()), "wlsimgbuilder_temp",
7474
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")));
75-
logger.info("tmp directory in user.home for docker run: " + tmpDir2);
75+
logger.info("tmp directory in for docker run: " + tmpDir2);
7676
Utils.copyResourceAsFile("/probe-env/test-update-env.sh",
7777
tmpDir2.toAbsolutePath().toString() + File.separator + "test-env.sh", true);
7878

@@ -131,7 +131,7 @@ public CommandResponse call() throws Exception {
131131
}
132132

133133
// create a tmp directory for user.
134-
tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("user.home")), "wlsimgbuilder_temp",
134+
tmpDir = Files.createTempDirectory(Paths.get(Utils.getBuildWorkingDir()), "wlsimgbuilder_temp",
135135
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")));
136136
String tmpDirPath = tmpDir.toAbsolutePath().toString();
137137
Path tmpPatchesDir = Files.createDirectory(Paths.get(tmpDirPath, "patches"));

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.io.PrintWriter;
1818
import java.net.URL;
1919
import java.nio.file.Files;
20+
import java.nio.file.LinkOption;
2021
import java.nio.file.Path;
2122
import java.nio.file.Paths;
2223
import java.nio.file.StandardCopyOption;
@@ -536,4 +537,33 @@ public static String getPasswordFromInputs(String passwordStr, Path passwordFile
536537
}
537538
return null;
538539
}
540+
541+
/**
542+
* returns the working dir for docker build
543+
* @return working directory
544+
*/
545+
public static String getBuildWorkingDir() throws IOException {
546+
String workingDir = System.getenv("WLSIMG_BLDDIR");
547+
if (workingDir == null ) {
548+
workingDir = System.getProperty("user.home");
549+
}
550+
Path path = Paths.get(workingDir);
551+
552+
boolean pathExists =
553+
Files.exists(path,
554+
new LinkOption[]{ LinkOption.NOFOLLOW_LINKS});
555+
556+
if (!pathExists) {
557+
throw new IOException("Working Directory does not exists " + workingDir);
558+
} else {
559+
if (!Files.isDirectory(path)) {
560+
throw new IOException("Working Directory specified is not a directory " + workingDir);
561+
}
562+
if (!Files.isWritable(path)) {
563+
throw new IOException("Working Directory specified is not writable " + workingDir);
564+
}
565+
}
566+
567+
return workingDir;
568+
}
539569
}

imagetool/src/main/resources/docker-files/Dockerfile.create

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ FROM ${BASE_IMAGE} as FINAL_BUILD
7777

7878
ARG JAVA_HOME=/u01/jdk
7979
ARG ORACLE_HOME=/u01/oracle
80-
ARG DOMAIN_NAME
8180
ARG DOMAIN_PARENT
81+
ARG DOMAIN_HOME
8282
ARG ADMIN_NAME
8383
ARG ADMIN_HOST
8484
ARG ADMIN_PORT
@@ -93,14 +93,13 @@ ENV ORACLE_HOME=${ORACLE_HOME} \
9393
MANAGED_SERVER_PORT=${MANAGED_SERVER_PORT:-8001} \
9494
WLSDEPLOY_PROPERTIES="-Djava.security.egd=file:/dev/./urandom" \
9595
DOMAIN_PARENT=${DOMAIN_PARENT:-/u01/domains} \
96-
DOMAIN_NAME=${DOMAIN_NAME:-base_domain} \
9796
LC_ALL=${DEFAULT_LOCALE:-en_US.UTF-8} \
9897
PROPERTIES_FILE_DIR=$ORACLE_HOME/properties
9998

10099
# DO NOT COMBINE THESE BLOCKS. It won't work when formatting variables like DOMAIN_HOME
101-
ENV DOMAIN_HOME=${DOMAIN_PARENT}/${DOMAIN_NAME} \
100+
ENV DOMAIN_HOME=${DOMAIN_HOME:-/u01/domains/base_domain} \
102101
PROPERTIES_FILE_DIR=$ORACLE_HOME/properties \
103-
PATH=$PATH:${JAVA_HOME}/bin:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${DOMAIN_PARENT}/${DOMAIN_NAME}:${DOMAIN_PARENT}/${DOMAIN_NAME}/bin:${ORACLE_HOME}
102+
PATH=$PATH:${JAVA_HOME}/bin:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${DOMAIN_HOME}/bin:${ORACLE_HOME}
104103

105104
## Create oracle user
106105
RUN if [ -z "$(getent group oracle)" ]; then hash groupadd &> /dev/null && groupadd -g 1000 oracle || exit -1 ; fi \
@@ -110,6 +109,7 @@ RUN if [ -z "$(getent group oracle)" ]; then hash groupadd &> /dev/null && group
110109

111110
COPY --from=JDK_BUILD --chown=oracle:oracle $JAVA_HOME $JAVA_HOME/
112111
COPY --from=WLS_BUILD --chown=oracle:oracle $ORACLE_HOME $ORACLE_HOME/
112+
113113
# PLACEHOLDER FOR %%WDT_COPY_DOMAIN%% #
114114

115115
USER oracle

imagetool/src/main/resources/docker-files/Dockerfile.ph

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ ARG ORACLE_HOME=/u01/oracle
1313
ARG WDT_PKG
1414
ARG WDT_MODEL
1515
ARG DOMAIN_TYPE
16-
ARG DOMAIN_NAME
1716
ARG DOMAIN_PARENT
1817
ARG DOMAIN_HOME
1918
ARG WDT_ARCHIVE
@@ -26,7 +25,7 @@ ARG SCRIPTS_DIR
2625
ARG WDT_HOME
2726
ARG RCU_RUN_FLAG
2827

29-
RUN echo ${WLS_PKG} ${JAVA_PKG} ${WDT_MODEL}
28+
#RUN echo ${WLS_PKG} ${JAVA_PKG} ${WDT_MODEL} ${OTMPDIR}
3029

3130
ENV WDT_PKG=${WDT_PKG:-weblogic-deploy.zip} \
3231
ADMIN_NAME=${ADMIN_NAME:-admin-server} \
@@ -38,29 +37,27 @@ ENV WDT_PKG=${WDT_PKG:-weblogic-deploy.zip} \
3837
WLSDEPLOY_PROPERTIES="-Djava.security.egd=file:/dev/./urandom" \
3938
DOMAIN_TYPE=${DOMAIN_TYPE:-WLS} \
4039
DOMAIN_PARENT=${DOMAIN_PARENT:-/u01/domains} \
41-
DOMAIN_NAME=${DOMAIN_NAME:-base_domain} \
4240
WDT_ARCHIVE=${WDT_ARCHIVE:-} \
4341
WDT_VARIABLE=${WDT_VARIABLE:-} \
4442
LC_ALL=${DEFAULT_LOCALE:-en_US.UTF-8} \
4543
PROPERTIES_FILE_DIR=$ORACLE_HOME/properties \
4644
WDT_HOME=${WDT_HOME:-/u01/app/weblogic-deploy} \
4745
SCRIPTS_DIR=${SCRIPTS_DIR:-scripts} \
46+
OTMPDIR=${OTMPDIR:-/tmp/delme} \
4847
RCU_RUN_FLAG=${RCU_RUN_FLAG:-}
4948

5049
# DO NOT COMBINE THESE BLOCKS. It won't work when formatting variables like DOMAIN_HOME
51-
ENV DOMAIN_HOME=${DOMAIN_PARENT}/${DOMAIN_NAME} \
52-
SCRIPT_HOME=${DOMAIN_PARENT}/${DOMAIN_NAME} \
53-
PATH=$PATH:${JAVA_HOME}/bin:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${DOMAIN_PARENT}/${DOMAIN_NAME}:${DOMAIN_PARENT}/${DOMAIN_NAME}/bin:${ORACLE_HOME}
50+
ENV DOMAIN_HOME=${DOMAIN_HOME:-/u01/domains/base_domain} \
51+
PATH=$PATH:${JAVA_HOME}/bin:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${DOMAIN_HOME}/bin:${ORACLE_HOME}
5452

5553
COPY --from=JDK_BUILD --chown=oracle:oracle $JAVA_HOME $JAVA_HOME/
5654
COPY --from=WLS_BUILD --chown=oracle:oracle $ORACLE_HOME $ORACLE_HOME/
5755
COPY --chown=oracle:oracle ${WDT_PKG} ${WDT_MODEL} ${WDT_ARCHIVE} ${WDT_VARIABLE} ${OTMPDIR}/
58-
COPY --chown=oracle:oracle ${SCRIPTS_DIR}/*.sh ${SCRIPT_HOME}/
56+
#COPY --chown=oracle:oracle ${SCRIPTS_DIR}/*.sh ${SCRIPT_HOME}/
5957

6058
USER oracle
6159

6260
RUN unzip $OTMPDIR/$WDT_PKG -d $(dirname $WDT_HOME) \
63-
&& chmod a+x $SCRIPT_HOME/*.sh \
6461
&& mkdir -p $(dirname ${DOMAIN_HOME}) \
6562
&& mkdir -p ${PROPERTIES_FILE_DIR} \
6663
&& if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file ${OTMPDIR}/${WDT_MODEL##*/}"; fi \
@@ -77,15 +74,14 @@ RUN unzip $OTMPDIR/$WDT_PKG -d $(dirname $WDT_HOME) \
7774
$VARIABLE_OPT \
7875
$MODEL_OPT \
7976
$ARCHIVE_OPT \
80-
&& chmod -R a+x ${DOMAIN_HOME}/bin/*.sh \
8177
&& rm -rf ${JAVA_HOME} ${ORACLE_HOME} ${WDT_HOME} $OTMPDIR
8278

8379
# END %%WDT_INSTALL%% #
8480

8581
# START %%WDT_CMD%% #
8682
# Expose admin server, managed server port
8783
EXPOSE $ADMIN_PORT $MANAGED_SERVER_PORT
88-
CMD ["sh", "-c", "${DOMAIN_HOME}/startAdminServer.sh"]
84+
#CMD ["sh", "-c", "${DOMAIN_HOME}/startAdminServer.sh"]
8985

9086
# END %%WDT_CMD%% #
9187

0 commit comments

Comments
 (0)