FROM python:3.14-alpine3.23 AS builder
WORKDIR /work
# Build-time dependencies: compiler and Python build tools
RUN apk add --no-cache --virtual .build-deps build-base libffi-dev openssl-dev && \
python -m pip install --upgrade pip && \
python -m pip install build poetry-core==2.4.0
# Copy the project sources and build the wheel
COPY . .
RUN python -m build
# Final runtime image
FROM python:3.14-alpine3.23
ENV PYTHONUNBUFFERED=1
# Runtime dependencies
RUN apk add --no-cache libffi openssl
WORKDIR /poetry
# Copy built wheel from the builder stage and install it
COPY --from=builder /work/dist/poetry-2.4.1-py3-none-any.whl /tmp/poetry-2.4.1-py3-none-any.whl
RUN python -m pip install /tmp/poetry-2.4.1-py3-none-any.whl
# Basic validation
RUN poetry --version
CMD ["poetry"]
__pycache__/ .git/ build/ dist/ *.egg-info/ *.tox/ *.venv/ venv/ *.egg *.pytest_cache/ *.pytest_cache .cache/ *.pyc
Concerns: The FROM image uses a Python 3.14 tag which may not exist in standard registries (risk of build failure)., The final stage copies a wheel with a hard-coded name (poetry-2.4.1-py3-none-any.whl); if the project version changes, this path will break unless the name is updated accordingly., CMD invokes poetry directly without a subcommand; while functional, startup UX may be suboptimal, though not a correctness issue. Smoke [PASS]: set -e -o pipefail; poetry new sample-project --src; test -d sample-project && test -f sample-project/pyproject.toml && grep -q 'tool.poetry' sample-project/pyproject.toml Smoke [FAIL]: set -e -o pipefail; mkdir -p /tmp/poetry-smoke2; cd /tmp/poetry-smoke2; poetry init -n; test -f pyproject.toml && grep -q 'tool.poetry' pyproject.toml Output:
Image python:3.14-alpine3.23 exists on Docker Hub.
Concerns: Hard-coded wheel filename in the multi-stage build (poetry-2.4.1-py3-none-any.whl) may break if the built wheel name changes., From image tag python:3.14-alpine3.23 may not exist in the registry, risking build failure due to an invalid base image tag., Relying on a fixed wheel name and path reduces maintainability and portability of the Dockerfile. Smoke [PASS]: poetry new smoke_tool --src && test -d smoke_tool/src/smoke_tool && test -f smoke_tool/pyproject.toml && grep -q 'tool.poetry' smoke_tool/pyproject.toml