|
|
|
FROM python:3.10.15-slim as builder |
|
|
|
LABEL maintainer="Soutrik soutrik1991@gmail.com" \ |
|
description="Docker image for running a Python app with dependencies managed by Poetry." |
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl && \ |
|
curl -sSL https://install.python-poetry.org | python3 - && \ |
|
apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
ENV PATH="/root/.local/bin:$PATH" |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY pyproject.toml poetry.lock /app/ |
|
|
|
|
|
ENV POETRY_NO_INTERACTION=1 \ |
|
POETRY_VIRTUALENVS_IN_PROJECT=1 \ |
|
POETRY_CACHE_DIR=/tmp/poetry_cache |
|
|
|
|
|
RUN --mount=type=cache,target=/tmp/poetry_cache poetry install --only main --no-root |
|
|
|
|
|
RUN poetry run pip uninstall -y cryptography && \ |
|
poetry add cryptography --lock |
|
|
|
|
|
FROM python:3.10.15-slim as runner |
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl && \ |
|
apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
COPY src /app/src |
|
COPY main.py /app/main.py |
|
|
|
|
|
COPY --from=builder /app/.venv /app/.venv |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
ENV PATH="/app/.venv/bin:$PATH" |
|
|
|
|
|
CMD ["python", "-m", "main"] |
|
|