forked from mtusi2026/mtusi2026lab2
31 lines
911 B
Docker
31 lines
911 B
Docker
# Pinned base image (lab2). Update digest when bumping Python.
|
|
FROM python:3.12.8-slim-bookworm AS runtime
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
APP_HOST=0.0.0.0 \
|
|
APP_PORT=8080 \
|
|
PYTHONPATH=/app/src \
|
|
MIGRATIONS_DIR=/app/migrations
|
|
|
|
WORKDIR /app
|
|
|
|
RUN groupadd --system --gid 10001 app \
|
|
&& useradd --system --uid 10001 --gid app --home /app --shell /usr/sbin/nologin app
|
|
|
|
COPY --chown=app:app requirements.txt .
|
|
RUN pip install --no-cache-dir --upgrade pip==24.3.1 \
|
|
&& pip install --no-cache-dir --retries 10 --timeout 60 -r requirements.txt
|
|
|
|
COPY --chown=app:app src ./src
|
|
COPY --chown=app:app migrations ./migrations
|
|
|
|
USER app
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=5s --timeout=3s --start-period=15s --retries=5 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2)"
|
|
|
|
CMD ["python", "-m", "messenger"]
|