diff --git a/Dockerfile b/Dockerfile index 5a1fbea..496b244 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,11 @@ +# Stage 1: Define a minimal stage to extract the 'uv' binary +# This is a multi-stage build to use uv for dependency management and is necessary to ensure the the image version we pull is for the right architecture. +# This is automatically set by the buildx builder. when using --platoform linux/amd64,linux/arm64 argument and then +# using FROM in the Dockerfile. +FROM ghcr.io/astral-sh/uv:0.4.0 AS uv_extractor + + +# Stage 2: The main application build stage FROM python:3.12-slim ARG TARGETARCH @@ -39,7 +47,11 @@ ENV SHELL=/bin/bash ## Install dependencies and copy GitOps server. ## WORKDIR /app -COPY --from=ghcr.io/astral-sh/uv:0.4.0 /uv /bin/uv + + + +# Copy the uv binary from the uv image to the final image. +COPY --from=uv_extractor /uv /bin/uv COPY --link=true pyproject.toml uv.lock /app/ RUN --mount=type=cache,target=/root/.cache/ \ (uv sync --frozen --no-install-project --extra server || uv sync --frozen --no-install-project --extra server)