@@ -12,17 +12,23 @@ LABEL org.opencontainers.image.source="https://github.com/aboutcode-org/dejacode
1212LABEL org.opencontainers.image.description="DejaCode"
1313LABEL org.opencontainers.image.licenses="AGPL-3.0-only"
1414
15- ENV APP_NAME dejacode
16- ENV APP_USER app
17- ENV APP_DIR /opt/$APP_NAME
18- ENV VENV_LOCATION /opt/$APP_NAME/.venv
15+ # Set default values for APP_UID and APP_GID at build-time
16+ ARG APP_UID=1000
17+ ARG APP_GID=1000
18+
19+ ENV APP_NAME=dejacode
20+ ENV APP_USER=app
21+ ENV APP_UID=${APP_UID}
22+ ENV APP_GID=${APP_GID}
23+ ENV APP_DIR=/opt/$APP_NAME
24+ ENV VENV_LOCATION=/opt/$APP_NAME/.venv
1925
2026# Force Python unbuffered stdout and stderr (they are flushed to terminal immediately)
21- ENV PYTHONUNBUFFERED 1
27+ ENV PYTHONUNBUFFERED= 1
2228# Do not write Python .pyc files
23- ENV PYTHONDONTWRITEBYTECODE 1
29+ ENV PYTHONDONTWRITEBYTECODE= 1
2430# Add the app dir in the Python path for entry points availability
25- ENV PYTHONPATH $PYTHONPATH:$APP_DIR
31+ ENV PYTHONPATH= $PYTHONPATH:$APP_DIR
2632
2733# OS requirements
2834RUN apt-get update \
@@ -36,9 +42,9 @@ RUN apt-get update \
3642 && apt-get clean \
3743 && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3844
39- # Create the APP_USER group, user, and directory with proper permissions
40- RUN addgroup --system $APP_USER \
41- && adduser --system --group --home= $APP_DIR $APP_USER \
45+ # Create the APP_USER group, user, and directory with specific UID and GID
46+ RUN groupadd --gid $APP_GID --system $APP_USER \
47+ && useradd --uid $APP_UID --gid $APP_GID --home-dir $APP_DIR --system --create-home $APP_USER \
4248 && chown $APP_USER:$APP_USER $APP_DIR \
4349 && mkdir -p /var/$APP_NAME \
4450 && chown $APP_USER:$APP_USER /var/$APP_NAME
@@ -53,7 +59,7 @@ RUN mkdir -p /var/$APP_NAME/static/ /var/$APP_NAME/media/
5359# Create the virtualenv
5460RUN python -m venv $VENV_LOCATION
5561# Enable the virtualenv, similar effect as "source activate"
56- ENV PATH $VENV_LOCATION/bin:$PATH
62+ ENV PATH= $VENV_LOCATION/bin:$PATH
5763
5864# Install the dependencies before the codebase COPY for proper Docker layer caching
5965COPY --chown=$APP_USER:$APP_USER setup.cfg setup.py $APP_DIR/
0 commit comments