Skip to content

Commit c755a5f

Browse files
committed
Merge branch 'os-package-override' into 'main'
Added new environment variable WLSIMG_OS_PACKAGES to allow override of OS packages See merge request weblogic-cloud/weblogic-image-tool!473
2 parents 08a3086 + 0555a9f commit c755a5f

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: "Configuration"
3+
date: 2024-04-16T08:00:00-05:00
4+
draft: false
5+
weight: 5
6+
---
7+
8+
The default configuration is typically adequate for common use. But, the following environment variables are provided for
9+
non-typical use cases when the default values are insufficient.
10+
11+
### Environment variables
12+
13+
- `WLSIMG_CACHEDIR` - When Image Tool downloads patches, those patches are saved in the cache directory. Setting this variable to another directory overrides the default of the `cache` folder in the user's home directory.
14+
- `WLSIMG_BUILDER` - During the build process, Image Tool creates a Docker context directory where it will create a Dockerfile and copy necessary files for the container image build. Setting this variable to another directory overrides the default of the user's home directory for the parent folder of the Docker context directory.
15+
- `WLSIMG_OS_PACKAGES` - There are several packages and libraries that are required by the WebLogic Kubernetes Toolkit. The default packages included at build time are `gzip tar unzip libaio libnsl jq findutils diffutils`. The names for those libraries can be different depending on your preferred Linux distribution or OS version. The value that you provide in this environment variable will be used in place of the default package list.
16+

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

+27-10
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
import java.nio.file.Path;
88
import java.nio.file.Paths;
99
import java.util.ArrayList;
10+
import java.util.Arrays;
1011
import java.util.Collections;
1112
import java.util.List;
1213
import java.util.Map;
1314
import java.util.StringJoiner;
1415
import java.util.concurrent.Callable;
1516
import java.util.stream.Collectors;
17+
import java.util.stream.Stream;
1618

1719
import com.oracle.weblogic.imagetool.aru.AruPatch;
1820
import com.oracle.weblogic.imagetool.cli.menu.PackageManagerType;
@@ -35,6 +37,10 @@ public class DockerfileOptions {
3537
// Default location for the oraInst.loc
3638
private static final String DEFAULT_INV_LOC = "/u01/oracle";
3739

40+
private static final List<String> DEFAULT_OS_PACKAGES = Arrays.asList(
41+
"gzip", "tar", "unzip", "libaio", "libnsl", "jq", "findutils", "diffutils");
42+
private static final String WLSIMG_OS_PACKAGES = System.getenv("WLSIMG_OS_PACKAGES");
43+
3844
private static final String DEFAULT_ORAINV_DIR = "/u01/oracle/oraInventory";
3945

4046
final String buildId;
@@ -964,16 +970,6 @@ public List<String> patches() {
964970
return patchFilenames;
965971
}
966972

967-
/**
968-
* Referenced by Dockerfile template, provides additional OS packages supplied by the user.
969-
*
970-
* @return list of commands as Strings.
971-
*/
972-
@SuppressWarnings("unused")
973-
public List<String> osPackages() {
974-
return getAdditionalCommandsForSection(AdditionalBuildCommands.PACKAGES);
975-
}
976-
977973
/**
978974
* Referenced by Dockerfile template, provides additional build commands supplied by the user.
979975
*
@@ -1140,4 +1136,25 @@ public DockerfileOptions buildArgs(String variableName) {
11401136
buildArgs.add(variableName);
11411137
return this;
11421138
}
1139+
1140+
/**
1141+
* Referenced by Dockerfile template, provides a list of packages that the package manager,
1142+
* like YUM, should install.
1143+
* @return a list of package names.
1144+
*/
1145+
@SuppressWarnings("unused")
1146+
public List<String> osPackages() {
1147+
List<String> result = new ArrayList<>(32);
1148+
if (Utils.isEmptyString(WLSIMG_OS_PACKAGES)) {
1149+
// If the user did not provide a list of OS packages, use the default list
1150+
result.addAll(DEFAULT_OS_PACKAGES);
1151+
} else {
1152+
// When provided in the environment variable, use the list of OS packages provided by the user.
1153+
result.addAll(Stream.of(WLSIMG_OS_PACKAGES.split(" ")).collect(Collectors.toList()));
1154+
}
1155+
1156+
result.addAll(getAdditionalCommandsForSection(AdditionalBuildCommands.PACKAGES));
1157+
1158+
return result;
1159+
}
11431160
}

imagetool/src/main/resources/docker-files/package-managers.mustache

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66
# Ensure necessary OS packages are installed
77
{{#useYum}}
88
RUN yum -y update \
9-
&& yum -y --downloaddir={{{tempDir}}} install gzip tar unzip libaio libnsl jq findutils diffutils {{#osPackages}}{{{.}}} {{/osPackages}}\
9+
&& yum -y --downloaddir={{{tempDir}}} install {{#osPackages}}{{{.}}} {{/osPackages}}\
1010
&& yum -y --downloaddir={{{tempDir}}} clean all \
1111
&& rm -rf /var/cache/yum/* \
1212
&& rm -rf {{{tempDir}}}
1313
{{/useYum}}
1414
{{#useDnf}}
1515
RUN dnf -y update \
16-
&& dnf -y install gzip tar unzip libaio libnsl jq findutils diffutils {{#osPackages}}{{{.}}} {{/osPackages}}\
16+
&& dnf -y install {{#osPackages}}{{{.}}} {{/osPackages}}\
1717
&& dnf clean all
1818
{{/useDnf}}
1919
{{#useMicroDnf}}
2020
RUN microdnf -y update \
21-
&& microdnf -y install gzip tar unzip libaio libnsl jq findutils diffutils shadow-utils {{#osPackages}}{{{.}}} {{/osPackages}}\
21+
&& microdnf -y install {{#osPackages}}{{{.}}} {{/osPackages}}\
2222
&& microdnf clean all
2323
{{/useMicroDnf}}
2424
{{#useMicroDnf8}}
2525
RUN microdnf update \
26-
&& microdnf install gzip tar unzip libaio libnsl jq findutils diffutils shadow-utils {{#osPackages}}{{{.}}} {{/osPackages}}\
26+
&& microdnf install {{#osPackages}}{{{.}}} {{/osPackages}}\
2727
&& microdnf clean all
2828
{{/useMicroDnf8}}
2929
{{#useAptGet}}
3030
RUN apt-get -y update \
3131
&& apt-get -y upgrade \
32-
&& apt-get -y install gzip tar unzip libaio libnsl jq findutils diffutils {{#osPackages}}{{{.}}} {{/osPackages}}\
32+
&& apt-get -y install {{#osPackages}}{{{.}}} {{/osPackages}}\
3333
&& apt-get -y clean all
3434
{{/useAptGet}}
3535
{{#useApk}}

0 commit comments

Comments
 (0)