# syntax=docker/dockerfile:1 FROM python:alpine # Create non-root user ARG CUSTOM_UID ARG CUSTOM_GID ENV CUSTOM_USERNAME=django ENV CUSTOM_GROUPNAME=django RUN addgroup --gid ${CUSTOM_GID:-1000} ${CUSTOM_GROUPNAME} && \ adduser --uid ${CUSTOM_UID:-1000} --shell /bin/ash ${CUSTOM_USERNAME} --ingroup ${CUSTOM_GROUPNAME} --disabled-password && \ mkdir /app && chown ${CUSTOM_UID:-1000}:${CUSTOM_GID:-1000} /app && chmod 700 /app ENV PATH "$PATH:/home/${CUSTOM_GROUPNAME}/.local/bin" # Copy source files WORKDIR /app COPY --chown=${CUSTOM_USERNAME}:${CUSTOM_GROUPNAME} app/ /app/ # Install dependencies USER ${CUSTOM_UID:-1000}:${CUSTOM_GID:-1000} RUN pip install -r requirements.txt # Run ASGI server EXPOSE 8000/tcp ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8000"]