Skip to content

Commit 384eb3e

Browse files
committed
Replaced OTMPDIR arg with template variable in DockerfileOptions.java
1 parent 21aa905 commit 384eb3e

File tree

3 files changed

+52
-39
lines changed

3 files changed

+52
-39
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class DockerfileOptions {
1717
private String groupname = "oracle";
1818
private String javaHome = "/u01/jdk";
1919
private String baseImageName = "oraclelinux:7-slim";
20+
private String tempDirectory = "/tmp/delme";
2021

2122
/**
2223
* Options to be used with the Mustache template.
@@ -170,4 +171,23 @@ public DockerfileOptions setWdtEnabled() {
170171
useWdt = true;
171172
return this;
172173
}
174+
175+
/**
176+
* Referenced by Dockerfile template, provides location where installers should write their temporary files.
177+
*
178+
* @return the full path to the temporary directory that should be used.
179+
*/
180+
public String tempDir() {
181+
return tempDirectory;
182+
}
183+
184+
/**
185+
* The location where installers should write their temporary files.
186+
*
187+
* @param value the full path to the temporary directory that should be used.
188+
*/
189+
public void setTempDirectory(String value) {
190+
191+
tempDirectory = value;
192+
}
173193
}

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

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ FROM {{baseImage}} as OS_UPDATE
88
USER root
99

1010
{{#useYum}}
11-
RUN yum -y --downloaddir=$OTMPDIR install gzip tar unzip \
12-
&& yum -y --downloaddir=$OTMPDIR clean all \
13-
&& rm -rf $OTMPDIR
11+
RUN yum -y --downloaddir={{tmpDir}} install gzip tar unzip \
12+
&& yum -y --downloaddir={{tmpDir}} clean all \
13+
&& rm -rf {{tmpDir}}
1414
{{/useYum}}
1515
{{#useAptGet}}
1616
RUN apt-get -y update \
@@ -37,27 +37,24 @@ RUN if [ -z "$(getent group {{groupid}})" ]; then hash groupadd &> /dev/null &&
3737

3838
FROM OS_UPDATE as JDK_BUILD
3939
ARG JAVA_PKG
40-
ARG OTMPDIR
4140

4241
ENV JAVA_PKG=${JAVA_PKG:-server-jre-*-linux-x64.tar.gz} \
43-
JAVA_HOME={{java_home}} \
44-
OTMPDIR=${OTMPDIR:-/tmp/delme}
42+
JAVA_HOME={{java_home}}
4543

46-
COPY --chown={{userid}}:{{groupid}} $JAVA_PKG $OTMPDIR/
44+
COPY --chown={{userid}}:{{groupid}} $JAVA_PKG {{tmpDir}}/
4745

4846
USER {{userid}}
4947

50-
RUN tar xzf $OTMPDIR/$JAVA_PKG -C /u01 \
48+
RUN tar xzf {{tmpDir}}/$JAVA_PKG -C /u01 \
5149
&& mv /u01/jdk* {{java_home}} \
52-
&& rm -rf $OTMPDIR
50+
&& rm -rf {{tmpDir}}
5351

5452
FROM OS_UPDATE as WLS_BUILD
5553
ARG WLS_PKG
5654
ARG INV_LOC
5755
ARG WLS_RESP
5856
ARG ORACLE_HOME=/u01/oracle
5957
ARG ORAINST
60-
ARG OTMPDIR
6158
ARG PATCHDIR
6259

6360
ENV WLS_PKG=${WLS_PKG:-fmw_12.2.1.3.0_wls_Disk1_1of1.zip} \
@@ -66,36 +63,35 @@ ENV WLS_PKG=${WLS_PKG:-fmw_12.2.1.3.0_wls_Disk1_1of1.zip} \
6663
INV_LOC=${INV_LOC:-/u01/oracle/oraInventory} \
6764
WLS_RESP=${WLS_RESP:-wls.rsp} \
6865
ORAINST=${ORAINST:-oraInst.loc} \
69-
OTMPDIR=${OTMPDIR:-/tmp/delme} \
7066
OPATCH_NO_FUSER=true \
7167
PATCHDIR=${PATCHDIR:-patches}
7268

7369
# Install base WLS
7470
COPY --from=JDK_BUILD --chown={{userid}}:{{groupid}} {{java_home}} {{java_home}}/
75-
COPY --chown={{userid}}:{{groupid}} $WLS_PKG $WLS_RESP $OTMPDIR/
71+
COPY --chown={{userid}}:{{groupid}} $WLS_PKG $WLS_RESP {{tmpDir}}/
7672
COPY --chown={{userid}}:{{groupid}} $ORAINST $INV_LOC/
7773
{{#isOpatchPatchingEnabled}}
78-
COPY --chown=oracle:oracle p28186730_139400_Generic.zip $OTMPDIR/opatch/
74+
COPY --chown=oracle:oracle p28186730_139400_Generic.zip {{tmpDir}}/opatch/
7975
{{/isOpatchPatchingEnabled}}
8076
{{#isPatchingEnabled}}
81-
COPY --chown=oracle:oracle $PATCHDIR/* $OTMPDIR/patches/
77+
COPY --chown=oracle:oracle $PATCHDIR/* {{tmpDir}}/patches/
8278
{{/isPatchingEnabled}}
8379

8480
USER {{userid}}
8581

86-
RUN unzip $OTMPDIR/$WLS_PKG -d $OTMPDIR \
87-
&& {{java_home}}/bin/java -Xmx1024m -jar $OTMPDIR/fmw_*.jar -silent ORACLE_HOME=$ORACLE_HOME \
88-
-responseFile $OTMPDIR/$WLS_RESP -invPtrLoc $INV_LOC/$ORAINST -ignoreSysPrereqs -force -novalidation \
82+
RUN unzip {{tmpDir}}/$WLS_PKG -d {{tmpDir}} \
83+
&& {{java_home}}/bin/java -Xmx1024m -jar {{tmpDir}}/fmw_*.jar -silent ORACLE_HOME=$ORACLE_HOME \
84+
-responseFile {{tmpDir}}/$WLS_RESP -invPtrLoc $INV_LOC/$ORAINST -ignoreSysPrereqs -force -novalidation \
8985
{{#isOpatchPatchingEnabled}}
90-
&& cd $OTMPDIR/opatch \
91-
&& {{java_home}}/bin/jar -xf $OTMPDIR/opatch/p28186730_139400_Generic.zip \
92-
&& {{java_home}}/bin/java -jar $OTMPDIR/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home=$ORACLE_HOME \
86+
&& cd {{tmpDir}}/opatch \
87+
&& {{java_home}}/bin/jar -xf {{tmpDir}}/opatch/p28186730_139400_Generic.zip \
88+
&& {{java_home}}/bin/java -jar {{tmpDir}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home=$ORACLE_HOME \
9389
{{/isOpatchPatchingEnabled}}
9490
{{#isPatchingEnabled}}
95-
&& $ORACLE_HOME/OPatch/opatch napply -silent -oh $ORACLE_HOME -phBaseDir $OTMPDIR/patches \
91+
&& $ORACLE_HOME/OPatch/opatch napply -silent -oh $ORACLE_HOME -phBaseDir {{tmpDir}}/patches \
9692
&& $ORACLE_HOME/OPatch/opatch util cleanup -silent -oh $ORACLE_HOME \
9793
{{/isPatchingEnabled}}
98-
&& rm -rf {{java_home}} $OTMPDIR
94+
&& rm -rf {{java_home}} {{tmpDir}}
9995

10096
{{#isWdtEnabled}}
10197
FROM OS_UPDATE as WDT_BUILD
@@ -133,7 +129,6 @@ ENV WDT_PKG=${WDT_PKG:-weblogic-deploy.zip} \
133129
PROPERTIES_FILE_DIR=$ORACLE_HOME/properties \
134130
WDT_HOME=${WDT_HOME:-/u01/app/weblogic-deploy} \
135131
SCRIPTS_DIR=${SCRIPTS_DIR:-scripts} \
136-
OTMPDIR=${OTMPDIR:-/tmp/delme} \
137132
RCU_RUN_FLAG=${RCU_RUN_FLAG:-}
138133

139134
# DO NOT COMBINE THESE BLOCKS. It won't work when formatting variables like DOMAIN_HOME
@@ -142,16 +137,16 @@ ENV DOMAIN_HOME=${DOMAIN_HOME:-/u01/domains/base_domain} \
142137

143138
COPY --from=JDK_BUILD --chown={{userid}}:{{groupid}} {{java_home}} {{java_home}}/
144139
COPY --from=WLS_BUILD --chown={{userid}}:{{groupid}} $ORACLE_HOME $ORACLE_HOME/
145-
COPY --chown={{userid}}:{{groupid}} ${WDT_PKG} ${WDT_MODEL} ${WDT_ARCHIVE} ${WDT_VARIABLE} ${OTMPDIR}/
140+
COPY --chown={{userid}}:{{groupid}} ${WDT_PKG} ${WDT_MODEL} ${WDT_ARCHIVE} ${WDT_VARIABLE} {{tmpDir}}/
146141

147142
USER {{userid}}
148143

149-
RUN unzip $OTMPDIR/$WDT_PKG -d $(dirname $WDT_HOME) \
144+
RUN unzip {{tmpDir}}/$WDT_PKG -d $(dirname $WDT_HOME) \
150145
&& mkdir -p $(dirname ${DOMAIN_HOME}) \
151146
&& mkdir -p ${PROPERTIES_FILE_DIR} \
152-
&& if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file ${OTMPDIR}/${WDT_MODEL##*/}"; fi \
153-
&& if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file ${OTMPDIR}/${WDT_ARCHIVE##*/}"; fi \
154-
&& if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file ${OTMPDIR}/${WDT_VARIABLE##*/}"; fi \
147+
&& if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file {{tmpDir}}/${WDT_MODEL##*/}"; fi \
148+
&& if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file {{tmpDir}}/${WDT_ARCHIVE##*/}"; fi \
149+
&& if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file {{tmpDir}}/${WDT_VARIABLE##*/}"; fi \
155150
&& if [ -n "${RCU_RUN_FLAG}" ]; then RCU_RUN_OPT="-run_rcu"; fi \
156151
&& cd ${WDT_HOME}/bin \
157152
&& ${WDT_HOME}/bin/createDomain.sh \
@@ -163,7 +158,7 @@ RUN unzip $OTMPDIR/$WDT_PKG -d $(dirname $WDT_HOME) \
163158
$VARIABLE_OPT \
164159
$MODEL_OPT \
165160
$ARCHIVE_OPT \
166-
&& rm -rf {{java_home}} ${ORACLE_HOME} ${WDT_HOME} $OTMPDIR
161+
&& rm -rf {{java_home}} ${ORACLE_HOME} ${WDT_HOME} {{tmpDir}}
167162
{{/isWdtEnabled}}
168163

169164
FROM {{baseImage}} as FINAL_BUILD

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ FROM {{baseImage}} as OS_UPDATE
99
USER root
1010

1111
ARG PATCHDIR
12-
ARG OTMPDIR
1312

1413
ENV PATCHDIR=${PATCHDIR:-patches} \
15-
OTMPDIR=${OTMPDIR:-/tmp/delme} \
1614
OPATCH_NO_FUSER=true
1715

1816
USER {{userid}}
1917

2018
{{#isOpatchPatchingEnabled}}
21-
COPY --chown={{userid}}:{{groupid}} p28186730_139400_Generic.zip $OTMPDIR/opatch/
22-
RUN cd $OTMPDIR/opatch \
23-
&& $JAVA_HOME/bin/jar -xf $OTMPDIR/opatch/p28186730_139400_Generic.zip \
24-
&& $JAVA_HOME/bin/java -jar $OTMPDIR/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home=$ORACLE_HOME \
25-
&& rm -rf $OTMPDIR
19+
COPY --chown={{userid}}:{{groupid}} p28186730_139400_Generic.zip {{tmpDir}}/opatch/
20+
RUN cd {{tmpDir}}/opatch \
21+
&& $JAVA_HOME/bin/jar -xf {{tmpDir}}/opatch/p28186730_139400_Generic.zip \
22+
&& $JAVA_HOME/bin/java -jar {{tmpDir}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home=$ORACLE_HOME \
23+
&& rm -rf {{tmpDir}}
2624
{{/isOpatchPatchingEnabled}}
2725

2826
{{#isPatchingEnabled}}
29-
COPY --chown={{userid}}:{{groupid}} $PATCHDIR/* $OTMPDIR/patches/
27+
COPY --chown={{userid}}:{{groupid}} $PATCHDIR/* {{tmpDir}}/patches/
3028

31-
RUN $ORACLE_HOME/OPatch/opatch napply -silent -oh $ORACLE_HOME -phBaseDir $OTMPDIR/patches \
29+
RUN $ORACLE_HOME/OPatch/opatch napply -silent -oh $ORACLE_HOME -phBaseDir {{tmpDir}}/patches \
3230
&& $ORACLE_HOME/OPatch/opatch util cleanup -silent -oh $ORACLE_HOME \
33-
&& rm -rf $OTMPDIR
31+
&& rm -rf {{tmpDir}}
3432
{{/isPatchingEnabled}}

0 commit comments

Comments
 (0)