forked from mtusi2026/mtusi2026lab3
30 lines
830 B
Docker
30 lines
830 B
Docker
# Pinned base image. Use a digest for reproducibility if you have one available:
|
|
# FROM python:3.12.7-slim-bookworm@sha256:<digest>
|
|
FROM python:3.12.7-slim-bookworm
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
APP_HOST=0.0.0.0 \
|
|
APP_PORT=8080
|
|
|
|
WORKDIR /app
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
COPY src/ ./src/
|
|
|
|
RUN useradd --create-home --uid 10001 --shell /usr/sbin/nologin appuser \
|
|
&& chown -R appuser:appuser /app
|
|
USER appuser
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=2s --timeout=3s --start-period=5s --retries=2 \
|
|
CMD python -c "import sys,urllib.request; \
|
|
sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=2).status==200 else 1)"
|
|
|
|
CMD ["python", "-m", "src"]
|