Files
mtusi2026lab3/Dockerfile
T
2026-10-13 19:11:11 +03:00

25 lines
660 B
Docker

# Messenger API (lab3). One image for the "api" and "migrate" services.
FROM python:3.12.7-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app ./app
COPY scripts/migrate.py ./scripts/migrate.py
COPY migrations ./migrations
RUN useradd --create-home --uid 10001 appuser
USER appuser
EXPOSE 8080
# Exec form: python is PID 1 and receives SIGTERM from "docker stop" itself.
# (lab2 used "sh -c uvicorn ...": sh stayed PID 1, uvicorn never got SIGTERM
# and was killed together with the container instead of draining.)
CMD ["python", "-m", "app.server"]