21
21
22
22
# ## START: Container build time args for Elemental Server
23
23
# #
24
+ # Names of the Linux user account and group to run the Elemental Server service under
25
+ ARG ELEMENTAL_SERVER_SERVICE_ACCOUNT="edb01"
26
+ ARG ELEMENTAL_SERVER_SERVICE_GROUP="edb01"
27
+
24
28
# Elemental data cache size
25
29
ARG ELEMENTAL_SERVER_CACHE_MEM="256"
26
30
# Elemental maximum number of database brokers
@@ -43,6 +47,10 @@ ARG ADDITIONAL_JAVA_TOOL_OPTIONS
43
47
# Install latest JRE 21 in Chainguard Wolfi temporary builder image
44
48
FROM cgr.dev/chainguard/wolfi-base AS builder
45
49
50
+ # Inherit global args to this build stage
51
+ ARG ELEMENTAL_SERVER_SERVICE_ACCOUNT
52
+ ARG ELEMENTAL_SERVER_SERVICE_GROUP
53
+
46
54
RUN apk update && apk upgrade
47
55
# Install dependencies needed for JRE
48
56
RUN apk add tzdata zlib libjpeg-turbo libpng lcms2 freetype ttf-dejavu fontconfig-config libfontconfig1 expat libuuid libbrotlicommon1 libbrotlidec1 libbrotlienc1 libcrypt1
@@ -51,11 +59,17 @@ RUN apk add ca-certificates java-cacerts
51
59
# Install latest JRE
52
60
RUN apk add openjdk-21-jre
53
61
62
+ # Add Elemental Server service group and account
63
+ RUN addgroup -S ${ELEMENTAL_SERVER_SERVICE_GROUP} \
64
+ && adduser -S -G ${ELEMENTAL_SERVER_SERVICE_GROUP} -H -h /nonexistent -s /sbin/nologin -g "Elemental Database Server - Instance 01" ${ELEMENTAL_SERVER_SERVICE_ACCOUNT}
65
+
54
66
55
67
# Use Chainguard distroless glibc base for dynamically linked libraries
56
68
FROM cgr.dev/chainguard/glibc-dynamic:latest
57
69
58
70
# Inherit global args to this build stage
71
+ ARG ELEMENTAL_SERVER_SERVICE_ACCOUNT
72
+ ARG ELEMENTAL_SERVER_SERVICE_GROUP
59
73
ARG ELEMENTAL_SERVER_CACHE_MEM
60
74
ARG ELEMENTAL_SERVER_MAX_BROKER
61
75
ARG JVM_MAX_RAM_PERCENTAGE
@@ -93,17 +107,22 @@ COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates
93
107
# Copy over updated JRE from Wolfi
94
108
COPY --from=builder /usr/lib/jvm/java-21-openjdk /usr/lib/jvm/java-21-openjdk
95
109
96
- # Switch to nonroot user
97
- USER nonroot
110
+ # Copy Elemental Server service group and account
111
+ COPY --from=builder --chown=root:root --chmod=0644 /etc/passwd /etc/passwd
112
+ COPY --from=builder --chown=root:root --chmod=0644 /etc/group /etc/group
113
+ COPY --from=builder --chown=root:root --chmod=0600 /etc/shadow /etc/shadow
114
+
115
+ # Switch to Elemental Server service account
116
+ USER ${ELEMENTAL_SERVER_SERVICE_ACCOUNT}
98
117
99
118
# Copy Elemental
100
- COPY --chmod=0555 logs /elemental
101
- COPY --chmod=0444 LICENSE /elemental/LICENSE
102
- COPY --chmod=0570 autodeploy /elemental/autodeploy
103
- COPY --chmod=0570 etc /elemental/etc
104
- COPY --chmod=0550 lib /elemental/lib
105
- COPY --chown=nonroot --chmod=0750 logs /elemental/logs
106
- COPY --chown=nonroot --chmod=0750 logs /elemental/data
119
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} -- chmod=0555 logs /elemental
120
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} -- chmod=0444 LICENSE /elemental/LICENSE
121
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} -- chmod=0570 autodeploy /elemental/autodeploy
122
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} -- chmod=0570 etc /elemental/etc
123
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} -- chmod=0550 lib /elemental/lib
124
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} --chmod=0750 logs /elemental/logs
125
+ COPY --chown=${ELEMENTAL_SERVER_SERVICE_ACCOUNT}:${ELEMENTAL_SERVER_SERVICE_GROUP} --chmod=0750 logs /elemental/data
107
126
108
127
# Build-time metadata as defined at http://label-schema.org
109
128
# and used by autobuilder @hooks/build
0 commit comments