Files
mtusi2026lab3-fork/Dockerfile
T
2026-10-30 00:53:49 +03:00

30 lines
869 B
Docker

FROM python:3.12.15-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /app
RUN useradd --system --uid 10001 --no-create-home appuser
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY alembic.ini ./
COPY migrations ./migrations
COPY app ./app
USER appuser
# TODO(4.1): uvicorn корректно завершается по SIGTERM (сигнал Docker по умолчанию).
# Проверьте, что python — PID 1 (exec-форма CMD), иначе сигнал не дойдёт.
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD ["python", "-c", "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:' + os.environ['APP_PORT'] + '/health/live', timeout=2)"]
CMD ["python", "-m", "app"]