1
1
# syntax=docker/dockerfile:1
2
2
3
3
# # base image
4
- FROM python:3.12-slim as base
4
+ FROM python:3.12-slim AS base
5
5
6
6
ENV PYTHONUNBUFFERED=1 \
7
7
PYTHONDONTWRITEBYTECODE=1 \
8
- PIP_DISABLE_PIP_VERSION_CHECK=on \
9
- PIP_DEFAULT_TIMEOUT=100 \
10
- POETRY_VERSION="1.8.3" \
11
- POETRY_HOME="/opt/poetry" \
12
- POETRY_NO_INTERACTION=1 \
13
- VENV_PATH="/opt/venv" \
8
+ VENV_PATH="/opt/app/.venv" \
14
9
APP_HOME="/opt/app"
15
- ENV PATH="$POETRY_HOME/bin:$ VENV_PATH/bin:$PATH"
10
+ ENV PATH="$VENV_PATH/bin:$PATH"
16
11
ENV VIRTUAL_ENV=$VENV_PATH
17
12
18
13
RUN set -ex \
@@ -23,7 +18,7 @@ RUN set -ex \
23
18
24
19
25
20
# # builder-base image
26
- FROM base as builder-base
21
+ FROM base AS builder-base
27
22
RUN apt-get update && \
28
23
apt-get install --no-install-recommends -y \
29
24
curl \
@@ -32,32 +27,25 @@ RUN apt-get update && \
32
27
python3-dev \
33
28
&& rm -rf /var/lib/apt/lists/*
34
29
35
- RUN --mount=type=cache,target=/root/.cache \
36
- curl -sSL https://install.python-poetry.org | python -
30
+ COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
37
31
38
32
WORKDIR $APP_HOME
39
- COPY poetry .lock pyproject.toml ./
33
+ COPY uv .lock pyproject.toml ./
40
34
41
- RUN --mount=type=cache,target=/root/.cache \
42
- python -m venv $VENV_PATH && \
43
- poetry install --no-root --only=main
35
+ RUN uv sync --frozen
44
36
45
37
COPY . .
46
- RUN --mount=type=cache,target=/root/.cache \
47
- poetry install --only-root
48
38
49
39
50
40
# # dev image
51
- FROM base as dev
41
+ FROM base AS dev
52
42
53
- COPY --from=builder-base $POETRY_HOME $POETRY_HOME
54
- COPY --from=builder-base $VENV_PATH $VENV_PATH
55
43
COPY --from=builder-base $APP_HOME $APP_HOME
44
+ COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
56
45
57
46
WORKDIR $APP_HOME
58
47
59
- RUN --mount=type=cache,target=/root/.cache \
60
- poetry install --with=dev && \
48
+ RUN uv sync --frozen --dev && \
61
49
rm -rf $APP_HOME
62
50
63
51
EXPOSE 8000
@@ -67,22 +55,19 @@ CMD ["server", "--dev"]
67
55
68
56
69
57
# # ci image
70
- FROM base as ci
58
+ FROM base AS ci
71
59
72
- COPY --from=builder-base $POETRY_HOME $POETRY_HOME
73
- COPY --from=builder-base $VENV_PATH $VENV_PATH
74
60
COPY --from=builder-base $APP_HOME $APP_HOME
61
+ COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
75
62
76
63
WORKDIR $APP_HOME
77
64
78
- RUN --mount=type=cache,target=/root/.cache \
79
- poetry install --with=test
65
+ RUN uv sync --frozen --group=test
80
66
81
67
82
68
# # prod image
83
- FROM base as prod
69
+ FROM base AS prod
84
70
85
- COPY --from=builder-base $VENV_PATH $VENV_PATH
86
71
COPY --from=builder-base /opt/app /opt/app
87
72
88
73
WORKDIR $APP_HOME
0 commit comments