Skip to content

Commit 5757fdc

Browse files
authored
Added additional build command hook for --additionalBuildCommands prior at the beginning of the Dockerfile, initial-build-commands (#400)
1 parent ecd4ef2 commit 5757fdc

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

documentation/1.11/content/userguide/tools/create-aux-image.md

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Valid sections for `createAuxImage` are:
5252

5353
| Section | Available Variables | Build Stage | Timing |
5454
| --- | --- | --- | --- |
55+
| `initial-build-commands` | None | All | As root, and before any Image Tool actions. |
5556
| `package-manager-packages` | None | All | A list of OS packages, such as `ftp gzip`, separated by line or space. |
5657
| `final-build-commands` | `AUXILIARY_IMAGE_PATH` `WDT_HOME` `WDT_MODEL_HOME`| Final image | After all Image Tool actions are complete, and just before the container image is finalized. |
5758

documentation/1.11/content/userguide/tools/create-image.md

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Valid sections for create are:
7575

7676
| Section | Available Variables | Build Stage | Timing |
7777
| --- | --- | --- | --- |
78+
| `initial-build-commands` | None | All | As root, and before any Image Tool actions. |
7879
| `package-manager-packages` | None | All | A list of OS packages, such as `ftp gzip`, separated by line or space. |
7980
| `before-jdk-install` | `JAVA_HOME` | Intermediate (JDK_BUILD) | Before the JDK is installed. |
8081
| `after-jdk-install` | `JAVA_HOME` | Intermediate (JDK_BUILD) | After the JDK is installed. |

documentation/1.11/content/userguide/tools/rebase-image.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The input for this parameter is a simple text file that contains one or more of
5858

5959
| Section | Available Variables | Build Stage | Timing |
6060
| --- | --- | --- | --- |
61+
| `initial-build-commands` | None | All | As root, and before any Image Tool actions. |
6162
| `before-jdk-install` | `JAVA_HOME` `DOMAIN_HOME`| Intermediate (JDK_BUILD) | Before the JDK is installed. |
6263
| `after-jdk-install` | `JAVA_HOME` `DOMAIN_HOME` | Intermediate (JDK_BUILD) | After the JDK is installed. |
6364
| `before-fmw-install` | `JAVA_HOME` `ORACLE_HOME` `DOMAIN_HOME` | Intermediate (WLS_BUILD) | Before the Oracle Home is created. |

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

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class AdditionalBuildCommands {
2828
private static final LoggingFacade logger = LoggingFactory.getLogger(AdditionalBuildCommands.class);
2929

3030
public static final String PACKAGES = "package-manager-packages";
31+
public static final String INITIAL_BLD = "initial-build-commands";
3132
public static final String BEFORE_JDK = "before-jdk-install";
3233
public static final String AFTER_JDK = "after-jdk-install";
3334
public static final String BEFORE_FMW = "before-fmw-install";
@@ -48,6 +49,7 @@ public class AdditionalBuildCommands {
4849
public AdditionalBuildCommands(Path file) throws IOException {
4950
sections = new ArrayList<>();
5051
sections.add(getPattern(PACKAGES));
52+
sections.add(getPattern(INITIAL_BLD));
5153
sections.add(getPattern(BEFORE_JDK));
5254
sections.add(getPattern(AFTER_JDK));
5355
sections.add(getPattern(BEFORE_FMW));

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

+10
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,16 @@ public List<String> osPackages() {
967967
return getAdditionalCommandsForSection(AdditionalBuildCommands.PACKAGES);
968968
}
969969

970+
/**
971+
* Referenced by Dockerfile template, provides additional build commands supplied by the user.
972+
*
973+
* @return list of commands as Strings.
974+
*/
975+
@SuppressWarnings("unused")
976+
public List<String> initialBuildCommands() {
977+
return getAdditionalCommandsForSection(AdditionalBuildCommands.INITIAL_BLD);
978+
}
979+
970980
/**
971981
* Referenced by Dockerfile template, provides additional build commands supplied by the user.
972982
*

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

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
FROM {{baseImage}} as os_update
66
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
77
USER root
8+
{{#initialBuildCommands}}
9+
{{{.}}}
10+
{{/initialBuildCommands}}
811
# Use package manager to make sure that unzip, tar, and other required packages are installed
912
{{> package-managers}}
1013

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

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
1818

1919
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
2020
USER root
21+
{{#initialBuildCommands}}
22+
{{{.}}}
23+
{{/initialBuildCommands}}
2124
# Use package manager to make sure that unzip, tar, and other required packages are installed
2225
{{> package-managers}}
2326

imagetool/src/main/resources/docker-files/aux-image.mustache

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ FROM {{baseImage}} as os_update
99
LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
1010

1111
USER root
12-
12+
{{#initialBuildCommands}}
13+
{{{.}}}
14+
{{/initialBuildCommands}}
1315
# Use package manager to make sure that unzip, tar, and other required packages are installed
1416
{{> package-managers}}
1517

0 commit comments

Comments
 (0)