# syntax=docker/dockerfile:1 FROM python:3.12.12-slim-bookworm ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PYTHONPATH=/app/src \ APP_HOST=0.0.0.0 \ APP_PORT=8080 # Unprivileged user with a fixed UID; the application never runs as root. RUN groupadd --system --gid 10001 app \ && useradd --system --uid 10001 --gid app --no-create-home --shell /usr/sbin/nologin app WORKDIR /app COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt # Only the source code goes into the image (no .env, tests, evidence, .git). # Files stay owned by root, so the app user cannot modify its own code. COPY src/ /app/src/ ARG BUILD_REVISION=dev LABEL org.opencontainers.image.revision=${BUILD_REVISION} USER 10001:10001 EXPOSE 8080 # docker stop sends SIGTERM; the app drains and exits well within the 10 s budget. STOPSIGNAL SIGTERM HEALTHCHECK --interval=2s --timeout=2s --start-period=5s --retries=3 \ CMD ["python", "/app/src/healthcheck.py"] # Exec form: python is PID 1 and receives signals directly (no shell in between). CMD ["python", "-m", "messenger"]