-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (21 loc) · 892 Bytes
/
Dockerfile
File metadata and controls
33 lines (21 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# STAGE 1: Builder image, used to build the virtual environment
FROM python:3.12-bookworm AS builder
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV POETRY_CACHE_DIR=/tmp/poetry_cache
ENV POETRY_VIRTUALENVS_IN_PROJECT=1
ENV POETRY_VIRTUALENVS_CREATE=1
ENV PATH="/root/.local/bin:$PATH"
WORKDIR /app
COPY pyproject.toml ./
COPY poetry.lock ./
RUN touch README.md
RUN poetry install --no-interaction --no-root && rm -rf $POETRY_CACHE_DIR
##########################################################################
# STAGE 2: Runtime image, used to run the code in the virtual environment
FROM python:3.12-slim-bookworm AS runtime
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY pyproject.toml ./pyproject.toml
COPY src ./src
ENTRYPOINT ["uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8080"]