Skip to content

Commit 487d8ad

Browse files
committed
[feature] Add a 'debug' user to the DEBUG Docker Container and grant it sudo privileges
1 parent 6b80177 commit 487d8ad

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

exist-docker/src/main/resources-filtered/Dockerfile-DEBUG

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
ARG ELEMENTAL_SERVER_SERVICE_ACCOUNT="edb01"
2626
ARG ELEMENTAL_SERVER_SERVICE_GROUP="edb01"
2727

28+
# Name of the Linux user account to use for the interactive container user when needing to debug
29+
ARG ELEMENTAL_CONTAINER_DEBUG_USER_ACCOUNT="debug"
30+
2831
# Elemental data cache size
2932
ARG ELEMENTAL_SERVER_CACHE_MEM="256"
3033
# Elemental maximum number of database brokers
@@ -56,6 +59,7 @@ FROM cgr.dev/chainguard/wolfi-base
5659
# Inherit global args to this build stage
5760
ARG ELEMENTAL_SERVER_SERVICE_ACCOUNT
5861
ARG ELEMENTAL_SERVER_SERVICE_GROUP
62+
ARG ELEMENTAL_CONTAINER_DEBUG_USER_ACCOUNT
5963
ARG ELEMENTAL_SERVER_CACHE_MEM
6064
ARG ELEMENTAL_SERVER_MAX_BROKER
6165
ARG JVM_MAX_RAM_PERCENTAGE
@@ -76,6 +80,16 @@ RUN apk add openjdk-21
7680
RUN addgroup -S ${ELEMENTAL_SERVER_SERVICE_GROUP} \
7781
&& adduser -S -G ${ELEMENTAL_SERVER_SERVICE_GROUP} -H -h /nonexistent -s /sbin/nologin -g "Elemental Database Server - Instance 01" ${ELEMENTAL_SERVER_SERVICE_ACCOUNT}
7882

83+
# Add 'debug' user for interactive use, and add then to the Elemental Server service group
84+
RUN adduser -D -g "Elemental Docker Container - debug user" ${ELEMENTAL_CONTAINER_DEBUG_USER_ACCOUNT} \
85+
&& addgroup ${ELEMENTAL_CONTAINER_DEBUG_USER_ACCOUNT} ${ELEMENTAL_SERVER_SERVICE_GROUP}
86+
87+
# Install sudo
88+
RUN apk add sudo-rs
89+
COPY --chmod=0440 <<EOF /etc/sudoers.d/${ELEMENTAL_CONTAINER_DEBUG_USER_ACCOUNT}
90+
${ELEMENTAL_CONTAINER_DEBUG_USER_ACCOUNT} ALL = (ALL:ALL) NOPASSWD:ALL
91+
EOF
92+
7993
# Switch to Elemental Server service account
8094
USER ${ELEMENTAL_SERVER_SERVICE_ACCOUNT}
8195

0 commit comments

Comments
 (0)