Skip to content

Commit 40504bb

Browse files
committed
Use deterministic UID/GID in Dockerfile #1555
Signed-off-by: tdruez <[email protected]>
1 parent d9f50b1 commit 40504bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ LABEL org.opencontainers.image.licenses="Apache-2.0"
2828

2929
ENV APP_NAME scancodeio
3030
ENV APP_USER app
31+
ENV APP_UID=1000
32+
ENV APP_GID=1000
3133
ENV APP_DIR /opt/$APP_NAME
3234
ENV VENV_LOCATION /opt/$APP_NAME/.venv
3335

@@ -64,9 +66,9 @@ RUN apt-get update \
6466
&& apt-get clean \
6567
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
6668

67-
# Create the APP_USER group and user
68-
RUN addgroup --system $APP_USER \
69-
&& adduser --system --group --home=$APP_DIR $APP_USER \
69+
# Create the APP_USER group and user with specific UID and GID
70+
RUN groupadd --gid $APP_GID $APP_USER \
71+
&& useradd --uid $APP_UID --gid $APP_GID --home-dir $APP_DIR --create-home $APP_USER \
7072
&& chown $APP_USER:$APP_USER $APP_DIR
7173

7274
# Create the /var/APP_NAME directory with proper permission for APP_USER

0 commit comments

Comments
 (0)