Skip to content

Commit 4b63934

Browse files
authored
Add support for Alpine to Auxiliary image creation (#332)
1 parent 54e9ad6 commit 4b63934

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import picocli.CommandLine.Spec;
3434
import picocli.CommandLine.Unmatched;
3535

36-
import static com.oracle.weblogic.imagetool.util.Constants.BUSYBOX;
36+
import static com.oracle.weblogic.imagetool.util.Constants.BUSYBOX_OS_IDS;
3737

3838
public abstract class CommonOptions {
3939
private static final LoggingFacade logger = LoggingFactory.getLogger(CommonOptions.class);
@@ -205,8 +205,11 @@ public void copyOptionsFromImage() throws IOException, InterruptedException {
205205

206206
// If the OS is busybox, the Dockerfile needs to know in order to use the correct security commands
207207
OperatingSystemProperties os = OperatingSystemProperties.getOperatingSystemProperties(baseImageProperties);
208-
// If OS is BusyBox, set usingBusyBox() to true, else set to false.
209-
dockerfileOptions.usingBusybox(os.name() != null && os.name().equalsIgnoreCase(BUSYBOX));
208+
// If OS is a BusyBox type OS, set usingBusyBox() to true, else set to false.
209+
if (os.name() != null) {
210+
// if OS name is in BUSYBOX_OS_NAMES, set usingBusybox to true
211+
dockerfileOptions.usingBusybox(BUSYBOX_OS_IDS.stream().anyMatch(os.id()::equalsIgnoreCase));
212+
}
210213

211214
String pkgMgrProp = baseImageProperties.getProperty("packageManager", "YUM");
212215

imagetool/src/main/java/com/oracle/weblogic/imagetool/inspect/OperatingSystemProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static OperatingSystemProperties getOperatingSystemProperties(Properties
3333
OperatingSystemProperties result = new OperatingSystemProperties();
3434
result.id = removeQuotes(imageProperties.getProperty("__OS__ID"));
3535
result.version = removeQuotes(imageProperties.getProperty("__OS__VERSION"));
36+
if (result.version == null) {
37+
result.version = removeQuotes(imageProperties.getProperty("__OS__VERSION_ID"));
38+
}
3639
result.name = removeQuotes(imageProperties.getProperty("__OS__NAME"));
3740
return result;
3841
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
package com.oracle.weblogic.imagetool.util;
55

6+
import java.util.Arrays;
7+
import java.util.Collections;
8+
import java.util.List;
9+
610
public final class Constants {
711

812
public static final String ARU_UPDATES_HOST =
@@ -23,6 +27,7 @@ public final class Constants {
2327
public static final String PATCH_ID_REGEX = "^(\\d{8})(?:[_][0-9][0-9](?:\\.[0-9]){3,8}\\.(\\d+))?";
2428
public static final String RIGID_PATCH_ID_REGEX = "^(\\d{8})[_][0-9][0-9](?:\\.[0-9]){3,8}\\.(\\d+)";
2529
public static final String BUSYBOX = "busybox";
30+
public static final List<String> BUSYBOX_OS_IDS = Collections.unmodifiableList(Arrays.asList("bb", "alpine"));
2631
public static final String ORACLE_LINUX = "ghcr.io/oracle/oraclelinux:8-slim";
2732

2833
private Constants() {

imagetool/src/main/resources/docker-files/create-user-group.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
#
66
# Create user and group
77
{{^usingBusybox}}
8-
RUN if [ -z "$(getent group {{groupid}})" ]; then groupadd {{groupid}} || exit -1 ; fi \
9-
&& if [ -z "$(getent passwd {{userid}})" ]; then useradd -g {{groupid}} {{userid}} || exit -1; fi \
8+
RUN if [ -z "$(getent group {{groupid}})" ]; then groupadd {{groupid}} || exit 1 ; fi \
9+
&& if [ -z "$(getent passwd {{userid}})" ]; then useradd -g {{groupid}} {{userid}} || exit 1; fi \
1010
&& mkdir -p /u01 \
1111
&& chown {{userid}}:{{groupid}} /u01 \
1212
&& chmod 775 /u01
1313
{{/usingBusybox}}
1414
{{#usingBusybox}}
15-
RUN if [ -z "$(grep ^{{groupid}}: /etc/group)" ]; then addgroup {{groupid}} || exit -1 ; fi \
16-
&& if [ -z "$(grep ^{{userid}}: /etc/passwd)" ]; then adduser -D -G {{groupid}} {{userid}} || exit -1 ; fi
15+
RUN if [ -z "$(grep ^{{groupid}}: /etc/group)" ]; then addgroup {{groupid}} || exit 1 ; fi \
16+
&& if [ -z "$(grep ^{{userid}}: /etc/passwd)" ]; then adduser -D -G {{groupid}} {{userid}} || exit 1 ; fi
1717
{{/usingBusybox}}

0 commit comments

Comments
 (0)