Files
mtusi2026lab2/Dockerfile
T
Риц Дмитрий da5caa9137
Skeleton contracts / contracts (pull_request) Failing after 35s
ЛР 2 — PostgreSQL и сессии Redis
2026-11-06 01:53:02 +03:00

32 lines
1022 B
Docker

# 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/
USER 10001:10001
EXPOSE 8080
# docker stop sends SIGTERM; the app drains and exits well within the 10 s budget.
STOPSIGNAL SIGTERM
HEALTHCHECK --interval=10s --timeout=3s --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"]