2026-10-18 00:54:23 +02:00
|
|
|
# B-91 (SEC-51, SEC-52): base image pinned by digest, dependencies installed from a
|
|
|
|
|
# hash-checked lock file, process running as a non-root user.
|
|
|
|
|
# To update: `docker buildx imagetools inspect python:3.12-slim` for the digest, and
|
|
|
|
|
# `pip-compile --generate-hashes --strip-extras -o requirements.lock pyproject.toml` for the lock.
|
|
|
|
|
FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1
|
2026-07-21 11:14:56 +02:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-10-18 00:54:23 +02:00
|
|
|
COPY requirements.lock ./
|
|
|
|
|
RUN pip install --no-cache-dir --require-hashes --no-deps -r requirements.lock
|
|
|
|
|
|
2026-11-16 12:00:57 +01:00
|
|
|
# ADR-54: the Django project (`config/`, `apps/`). The previous FastAPI code (`app/`) is no longer
|
|
|
|
|
# part of the image; it stays in the repository until the old backend is removed (roadmap D1).
|
|
|
|
|
COPY pyproject.toml manage.py ./
|
|
|
|
|
COPY config ./config
|
|
|
|
|
COPY apps ./apps
|
2026-07-21 11:14:56 +02:00
|
|
|
|
2026-10-18 00:54:23 +02:00
|
|
|
RUN pip install --no-cache-dir --no-deps . \
|
2026-11-16 12:00:57 +01:00
|
|
|
&& DJANGO_DEBUG=true python manage.py collectstatic --noinput \
|
2026-10-18 00:54:23 +02:00
|
|
|
&& useradd --uid 1000 --no-create-home --shell /usr/sbin/nologin app
|
|
|
|
|
USER 1000:1000
|
2026-07-21 11:14:56 +02:00
|
|
|
|
2026-11-16 12:00:57 +01:00
|
|
|
EXPOSE 8000
|
2026-07-21 11:14:56 +02:00
|
|
|
|
2026-11-16 12:00:57 +01:00
|
|
|
# umask 077: the database and its WAL files are created readable by the app user only.
|
|
|
|
|
# The worker service overrides this command (`python manage.py run_worker`).
|
|
|
|
|
CMD ["/bin/sh", "-c", "umask 077; python manage.py migrate --noinput && exec gunicorn config.wsgi --bind 0.0.0.0:8000 --workers 2 --access-logfile - --forwarded-allow-ips \"${FORWARDED_ALLOW_IPS:-127.0.0.1}\""]
|