hackathon-ENGIN/Dockerfile
Jakub Famulski 2 5ebfdc389a
All checks were successful
ENGIN CI / Build, test and smoke (push) Successful in 56s
prod: run container with restricted privileges
2026-08-25 13:16:23 +02:00

52 lines
1.2 KiB
Docker

ARG PYTHON_IMAGE=python:3.12-slim@sha256:7a8b475003c4fe15a2cd4e55e5cfc2f3560bdc9333d624f24cdd6d4340fd7a17
ARG APP_UID=10001
ARG APP_GID=10001
FROM ${PYTHON_IMAGE} AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
COPY requirements-lock.txt ./
RUN pip install --no-cache-dir -r requirements-lock.txt
FROM base AS test
COPY . .
FROM base AS runtime
ARG APP_UID
ARG APP_GID
RUN groupadd --gid "${APP_GID}" engin \
&& useradd --uid "${APP_UID}" \
--gid "${APP_GID}" \
--create-home \
--home-dir /home/engin \
--shell /usr/sbin/nologin \
engin
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
XDG_CACHE_HOME=/tmp/.cache \
MPLCONFIGDIR=/tmp/matplotlib
COPY app.py ./
COPY engin/ ./engin/
COPY assets/ ./assets/
COPY .streamlit/ ./.streamlit/
COPY artifacts/ ./artifacts/
COPY test.csv predictions.csv prediction_diagnostics.csv ./
USER ${APP_UID}:${APP_GID}
EXPOSE 8501
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8501/_stcore/health', timeout=3)"
STOPSIGNAL SIGTERM
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=8501"]