Skip to content

Commit 5eef5e7

Browse files
authored
no functional changes, introduced reusable mustache templates (#259)
1 parent 441d407 commit 5eef5e7

File tree

6 files changed

+85
-158
lines changed

6 files changed

+85
-158
lines changed

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

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,9 @@
77
FROM {{baseImage}} as os_update
88
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
99
USER root
10+
{{> package-managers}}
1011

11-
{{#useYum}}
12-
RUN yum -y --downloaddir={{{tempDir}}} install gzip tar unzip libaio jq findutils {{#osPackages}}{{{.}}} {{/osPackages}}\
13-
&& yum -y --downloaddir={{{tempDir}}} clean all \
14-
&& rm -rf /var/cache/yum/* \
15-
&& rm -rf {{{tempDir}}}
16-
{{/useYum}}
17-
{{#useDnf}}
18-
RUN dnf -y install gzip tar unzip libaio jq findutils {{#osPackages}}{{{.}}} {{/osPackages}}\
19-
&& dnf clean all
20-
{{/useDnf}}
21-
{{#useMicroDnf}}
22-
RUN microdnf install gzip tar unzip libaio jq findutils diffutils shadow-utils {{#osPackages}}{{{.}}} {{/osPackages}}\
23-
&& microdnf clean all
24-
{{/useMicroDnf}}
25-
{{#useAptGet}}
26-
RUN apt-get -y update \
27-
&& apt-get -y upgrade \
28-
&& apt-get -y install gzip tar unzip libaio jq findutils {{#osPackages}}{{{.}}} {{/osPackages}}\
29-
&& apt-get -y clean all
30-
{{/useAptGet}}
31-
{{#useApk}}
32-
RUN apk update \
33-
&& apk upgrade \
34-
&& rm -rf /var/cache/apk/*
35-
{{/useApk}}
36-
{{#useZypper}}
37-
RUN zypper -nq update \
38-
&& zypper -nq clean \
39-
&& rm -rf /var/cache/zypp/*
40-
{{/useZypper}}
41-
42-
## Create user and group
43-
RUN if [ -z "$(getent group {{groupid}})" ]; then hash groupadd &> /dev/null && groupadd {{groupid}} || exit -1 ; fi \
44-
&& if [ -z "$(getent passwd {{userid}})" ]; then hash useradd &> /dev/null && useradd -g {{groupid}} {{userid}} || exit -1; fi \
45-
&& mkdir -p /u01 \
46-
&& chown {{userid}}:{{groupid}} /u01 \
47-
&& chmod 775 /u01
12+
{{> create-user-group}}
4813

4914
{{#installJava}}
5015
# Install Java
@@ -95,14 +60,6 @@ RUN mkdir -p {{{oracle_home}}} \
9560
{{/installPackages}}
9661
COPY --chown={{userid}}:{{groupid}} oraInst.loc {{inv_loc}}/
9762

98-
{{#isOpatchPatchingEnabled}}
99-
COPY --chown={{userid}}:{{groupid}} {{{opatchFileName}}} {{{tempDir}}}/opatch/
100-
{{/isOpatchPatchingEnabled}}
101-
102-
{{#isPatchingEnabled}}
103-
COPY --chown={{userid}}:{{groupid}} patches/* {{{tempDir}}}/patches/
104-
{{/isPatchingEnabled}}
105-
10663
USER {{userid}}
10764

10865
{{#beforeFmwInstall}}
@@ -118,27 +75,7 @@ RUN echo "INSTALLING MIDDLEWARE" \
11875
{{/installPackages}}
11976
&& chmod -R g+r {{{oracle_home}}}
12077

121-
{{#isOpatchPatchingEnabled}}
122-
RUN cd {{{tempDir}}}/opatch \
123-
&& {{{java_home}}}/bin/jar -xf {{{tempDir}}}/opatch/{{{opatchFileName}}} \
124-
&& {{{java_home}}}/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home={{{oracle_home}}}
125-
{{/isOpatchPatchingEnabled}}
126-
127-
{{#isPatchingEnabled}}
128-
{{^strictPatchOrdering}}
129-
# Apply all patches provided at the same time
130-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -nonrollbackable -phBaseDir {{{tempDir}}}/patches \
131-
&& test $? -eq 0 \
132-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
133-
{{/strictPatchOrdering}}
134-
{{#strictPatchOrdering}}
135-
# Apply one patch at a time in the order they were specified
136-
{{#patches}}
137-
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} -nonrollbackable {{{tempDir}}}/patches/{{{.}}}
138-
{{/patches}}
139-
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
140-
{{/strictPatchOrdering}}
141-
{{/isPatchingEnabled}}
78+
{{> fmw-patching}}
14279

14380
{{#afterFmwInstall}}
14481
{{{.}}}

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

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,9 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
2121

2222
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
2323
USER root
24+
{{> package-managers}}
2425

25-
{{#useYum}}
26-
RUN yum -y --downloaddir={{{tempDir}}} install gzip tar unzip libaio jq findutils diffutils \
27-
&& yum -y --downloaddir={{{tempDir}}} clean all \
28-
&& rm -rf /var/cache/yum/* \
29-
&& rm -rf {{{tempDir}}}
30-
{{/useYum}}
31-
{{#useDnf}}
32-
RUN dnf -y install gzip tar unzip libaio jq \
33-
&& dnf clean all
34-
{{/useDnf}}
35-
{{#useMicroDnf}}
36-
RUN microdnf install gzip tar unzip libaio jq findutils diffutils shadow-utils \
37-
&& microdnf clean all
38-
{{/useMicroDnf}}
39-
{{#useAptGet}}
40-
RUN apt-get -y update \
41-
&& apt-get -y upgrade \
42-
&& apt-get -y install gzip tar unzip libaio jq findutils diffutils \
43-
&& apt-get -y clean all
44-
{{/useAptGet}}
45-
{{#useApk}}
46-
RUN apk update \
47-
&& apk upgrade \
48-
&& rm -rf /var/cache/apk/*
49-
{{/useApk}}
50-
{{#useZypper}}
51-
RUN zypper -nq update \
52-
&& zypper -nq clean \
53-
&& rm -rf /var/cache/zypp/*
54-
{{/useZypper}}
55-
56-
## Create user and group
57-
RUN if [ -z "$(getent group {{groupid}})" ]; then hash groupadd &> /dev/null && groupadd {{groupid}} || exit -1 ; fi \
58-
&& if [ -z "$(getent passwd {{userid}})" ]; then hash useradd &> /dev/null && useradd -g {{groupid}} {{userid}} || exit -1; fi \
59-
&& mkdir -p /u01 \
60-
&& chown {{userid}}:{{groupid}} /u01 \
61-
&& chmod 775 /u01
26+
{{> create-user-group}}
6227

6328
{{#installJava}}
6429
# Install Java
@@ -110,14 +75,6 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
11075
{{/installPackages}}
11176
COPY --chown={{userid}}:{{groupid}} oraInst.loc {{inv_loc}}/
11277

113-
{{#isOpatchPatchingEnabled}}
114-
COPY --chown={{userid}}:{{groupid}} {{{opatchFileName}}} {{{tempDir}}}/opatch/
115-
{{/isOpatchPatchingEnabled}}
116-
117-
{{#isPatchingEnabled}}
118-
COPY --chown={{userid}}:{{groupid}} patches/* {{{tempDir}}}/patches/
119-
{{/isPatchingEnabled}}
120-
12178
USER {{userid}}
12279

12380
{{#beforeFmwInstall}}
@@ -133,27 +90,7 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
13390
{{/installPackages}}
13491
&& chmod -R g+r {{{oracle_home}}}
13592

136-
{{#isOpatchPatchingEnabled}}
137-
RUN cd {{{tempDir}}}/opatch \
138-
&& {{{java_home}}}/bin/jar -xf {{{tempDir}}}/opatch/{{{opatchFileName}}} \
139-
&& {{{java_home}}}/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home={{{oracle_home}}}
140-
{{/isOpatchPatchingEnabled}}
141-
{{#isPatchingEnabled}}
142-
{{^strictPatchOrdering}}
143-
# Apply all patches provided at the same time
144-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -nonrollbackable -phBaseDir {{{tempDir}}}/patches \
145-
&& test $? -eq 0 \
146-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
147-
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
148-
{{/strictPatchOrdering}}
149-
{{#strictPatchOrdering}}
150-
# Apply one patch at a time in the order they were specified
151-
{{#patches}}
152-
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} -nonrollbackable {{{tempDir}}}/patches/{{{.}}}
153-
{{/patches}}
154-
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
155-
{{/strictPatchOrdering}}
156-
{{/isPatchingEnabled}}
93+
{{> fmw-patching}}
15794

15895
{{#afterFmwInstall}}
15996
{{{.}}}

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

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,7 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
9797

9898
USER {{userid}}
9999

100-
{{#isOpatchPatchingEnabled}}
101-
COPY --chown={{userid}}:{{groupid}} {{{opatchFileName}}} {{{tempDir}}}/opatch/
102-
RUN cd {{{tempDir}}}/opatch \
103-
&& {{{java_home}}}/bin/jar -xf {{{tempDir}}}/opatch/{{{opatchFileName}}} \
104-
&& {{{java_home}}}/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home={{{oracle_home}}} \
105-
&& rm -rf {{{tempDir}}}
106-
{{/isOpatchPatchingEnabled}}
107-
108-
{{#isPatchingEnabled}}
109-
COPY --chown={{userid}}:{{groupid}} patches/* {{{tempDir}}}/patches/
110-
111-
{{^strictPatchOrdering}}
112-
# Apply all patches provided at the same time
113-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -nonrollbackable -phBaseDir {{{tempDir}}}/patches \
114-
&& test $? -eq 0 \
115-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
116-
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
117-
{{/strictPatchOrdering}}
118-
{{#strictPatchOrdering}}
119-
# Apply one patch at a time in the order they were specified
120-
{{#patches}}
121-
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} -nonrollbackable {{{tempDir}}}/patches/{{{.}}}
122-
{{/patches}}
123-
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
124-
{{/strictPatchOrdering}}
125-
{{/isPatchingEnabled}}
100+
{{> fmw-patching}}
126101

127102
{{#isWdtEnabled}}
128103
{{#modelOnly}}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# Copyright (c) 2021, Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
#
6+
# Create user and group
7+
RUN if [ -z "$(getent group {{groupid}})" ]; then hash groupadd &> /dev/null && groupadd {{groupid}} || exit -1 ; fi \
8+
&& if [ -z "$(getent passwd {{userid}})" ]; then hash useradd &> /dev/null && useradd -g {{groupid}} {{userid}} || exit -1; fi \
9+
&& mkdir -p /u01 \
10+
&& chown {{userid}}:{{groupid}} /u01 \
11+
&& chmod 775 /u01
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Copyright (c) 2021, Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
#
6+
# Update OPatch and apply WebLogic patches
7+
{{#isOpatchPatchingEnabled}}
8+
COPY --chown={{userid}}:{{groupid}} {{{opatchFileName}}} {{{tempDir}}}/opatch/
9+
RUN cd {{{tempDir}}}/opatch \
10+
&& {{{java_home}}}/bin/jar -xf {{{tempDir}}}/opatch/{{{opatchFileName}}} \
11+
&& {{{java_home}}}/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home={{{oracle_home}}} \
12+
&& rm -rf {{{tempDir}}}
13+
{{/isOpatchPatchingEnabled}}
14+
15+
{{#isPatchingEnabled}}
16+
COPY --chown={{userid}}:{{groupid}} patches/* {{{tempDir}}}/patches/
17+
18+
{{^strictPatchOrdering}}
19+
# Apply all patches provided at the same time
20+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -nonrollbackable -phBaseDir {{{tempDir}}}/patches \
21+
&& test $? -eq 0 \
22+
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
23+
{{/strictPatchOrdering}}
24+
{{#strictPatchOrdering}}
25+
# Apply one patch at a time in the order they were specified
26+
{{#patches}}
27+
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} -nonrollbackable {{{tempDir}}}/patches/{{{.}}}
28+
{{/patches}}
29+
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
30+
{{/strictPatchOrdering}}
31+
{{/isPatchingEnabled}}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) 2021, Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
#
6+
# Ensure necessary OS packages are installed
7+
{{#useYum}}
8+
RUN yum -y --downloaddir={{{tempDir}}} install gzip tar unzip libaio jq findutils diffutils {{#osPackages}}{{{.}}} {{/osPackages}}\
9+
&& yum -y --downloaddir={{{tempDir}}} clean all \
10+
&& rm -rf /var/cache/yum/* \
11+
&& rm -rf {{{tempDir}}}
12+
{{/useYum}}
13+
{{#useDnf}}
14+
RUN dnf -y install gzip tar unzip libaio jq findutils diffutils {{#osPackages}}{{{.}}} {{/osPackages}}\
15+
&& dnf clean all
16+
{{/useDnf}}
17+
{{#useMicroDnf}}
18+
RUN microdnf install gzip tar unzip libaio jq findutils diffutils shadow-utils {{#osPackages}}{{{.}}} {{/osPackages}}\
19+
&& microdnf clean all
20+
{{/useMicroDnf}}
21+
{{#useAptGet}}
22+
RUN apt-get -y update \
23+
&& apt-get -y upgrade \
24+
&& apt-get -y install gzip tar unzip libaio jq findutils diffutils {{#osPackages}}{{{.}}} {{/osPackages}}\
25+
&& apt-get -y clean all
26+
{{/useAptGet}}
27+
{{#useApk}}
28+
RUN apk update \
29+
&& apk upgrade \
30+
&& rm -rf /var/cache/apk/*
31+
{{/useApk}}
32+
{{#useZypper}}
33+
RUN zypper -nq update \
34+
&& zypper -nq clean \
35+
&& rm -rf /var/cache/zypp/*
36+
{{/useZypper}}

0 commit comments

Comments
 (0)