From 9f9cf51d0d4430f7a535341ff295b003b490d418 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Wed, 4 Jun 2025 14:03:34 +1000 Subject: [PATCH 1/2] fix: make sure to pull the right uv image for the target architecture --- Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5a1fbea..824aeb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,13 @@ 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 +# 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 + +# Copy the uv binary from the uv image to the final image. +COPY --from=uv /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) From 5f325cd7a7d28393057d34f3f377b124adfab6e7 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Wed, 4 Jun 2025 14:09:56 +1000 Subject: [PATCH 2/2] chore: fix the multi-stage circular dependency --- Dockerfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 824aeb8..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,13 +47,11 @@ ENV SHELL=/bin/bash ## Install dependencies and copy GitOps server. ## WORKDIR /app -# 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 + + # Copy the uv binary from the uv image to the final image. -COPY --from=uv /uv /bin/uv +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)