forked from mtusi2026/mtusi2026lab7
36 lines
971 B
Docker
36 lines
971 B
Docker
FROM python:3.12.14-slim-bookworm AS dependencies
|
|
|
|
ENV POETRY_VIRTUALENVS_IN_PROJECT=true \
|
|
POETRY_NO_INTERACTION=1
|
|
|
|
WORKDIR /app
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
pip install --timeout 30 --retries 8 "poetry==2.2.1"
|
|
COPY poetry.lock pyproject.toml ./
|
|
RUN --mount=type=cache,target=/root/.cache/pypoetry \
|
|
poetry config requests.max-retries 6 \
|
|
&& poetry install --only main --no-root
|
|
|
|
FROM python:3.12.14-slim-bookworm
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PATH="/app/.venv/bin:$PATH"
|
|
|
|
WORKDIR /app
|
|
COPY --from=dependencies /app/.venv /app/.venv
|
|
COPY migrations ./migrations
|
|
COPY src ./src
|
|
|
|
RUN useradd --uid 10001 --no-create-home app
|
|
USER app
|
|
|
|
ARG APP_REVISION=dev
|
|
ENV APP_REVISION=${APP_REVISION}
|
|
LABEL org.opencontainers.image.revision=${APP_REVISION}
|
|
|
|
EXPOSE 8080
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD ["python", "src/healthcheck.py"]
|
|
CMD ["python", "src/gateway.py"]
|