-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (32 loc) · 1.05 KB
/
Dockerfile
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
34
35
36
37
38
39
40
41
42
43
# Configure metadata
ARG POETRY_VERSION="1.3.2"
ARG PYTHON_VERSION="3.12"
ARG PYTHON_DIST="bookworm"
# --- builder ----
FROM "docker.io/library/python:${PYTHON_VERSION}-${PYTHON_DIST}" as builder
# Configure poetry environment variables
ARG POETRY_CACHE_DIR=/tmp/poetry_cache
ENV POETRY_NO_INTERACTION=1
ARG POETRY_VERSION
ENV POETRY_VIRTUALENVS_CREATE=1
ENV POETRY_VIRTUALENVS_IN_PROJECT=1
# Install poetry
RUN pip install --no-cache-dir "poetry==${POETRY_VERSION}"
# Load package metadata
WORKDIR /app
COPY pyproject.toml ./
# Install package dependencies
RUN --mount=type=cache,target=${POETRY_CACHE_DIR} \
poetry install --no-root --without dev
# --- runtime ----
FROM "docker.io/library/python:${PYTHON_VERSION}-slim-${PYTHON_DIST}" as runtime
# Configure entrypoint
ENTRYPOINT ["/usr/bin/env"]
# Configure runtime environment variables
ENV PATH="/app/.venv/bin:${PATH}"
# Load package source codes
WORKDIR /app
COPY --from=builder /app/.venv .venv
ADD ./ .
RUN chmod +x ./start.sh
CMD [ "bash","./start.sh" ]