Skip to content

Commit 6ad7e53

Browse files
committed
Rebuild over base image with poetry embedded
1 parent 3edf754 commit 6ad7e53

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Dockerfile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM python:3.12 AS builder
1+
ARG POETRY_VERSION=1.8.3
2+
ARG PYTHON_VERSION=3.12
23

3-
# --- Install Poetry ---
4-
ARG POETRY_VERSION=1.8
4+
FROM weastur/poetry:${POETRY_VERSION}-python-${PYTHON_VERSION} AS builder
55

66
ENV POETRY_HOME=/opt/poetry
77
ENV POETRY_NO_INTERACTION=1
@@ -12,7 +12,16 @@ ENV PYTHONUNBUFFERED=1
1212
# Tell Poetry where to place its cache and virtual environment
1313
ENV POETRY_CACHE_DIR=/opt/.cache
1414

15-
RUN pip install "poetry==${POETRY_VERSION}"
15+
# Install build-time deps for poetry and FFI
16+
RUN apt-get update \
17+
&& apt-get install -y --no-install-recommends \
18+
build-essential \
19+
g++ \
20+
gcc \
21+
libffi-dev \
22+
libssl-dev \
23+
pkg-config \
24+
&& rm -rf /var/lib/apt/lists/*
1625

1726
WORKDIR /usr/src/app
1827

@@ -23,11 +32,11 @@ COPY pyproject.toml poetry.lock /usr/src/app/
2332

2433
# Install the dependencies and clear the cache afterwards.
2534
# This may save some MBs.
26-
RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR
35+
RUN --mount=type=tmpfs,target=/root/.cargo poetry install --no-root && rm -rf $POETRY_CACHE_DIR
2736

2837
# Now let's build the runtime image from the builder.
2938
# We'll just copy the env and the PATH reference.
30-
FROM python:3.12-slim AS runtime
39+
FROM python:${PYTHON_VERSION}-slim AS runtime
3140

3241
WORKDIR /usr/src/app
3342

0 commit comments

Comments
 (0)