From 23b010c08f8f500ec2bd21076f53c361b6251c49 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 26 Sep 2024 17:19:14 +0300 Subject: [PATCH] Docker: put uv and uvx in a single layer (#7697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Copy both `uv` and `uvx` into place in a single Dockerfile command. [`COPY` supports multiple sources when the destination is a directory.](https://docs.docker.com/engine/reference/builder/#copy) As it is, e.g. `ghcr.io/astral-sh/uv:0.4.16-python3.12-bookworm-slim` has this (screenshot from [Dive](https://github.com/wagoodman/dive)): Screenshot 2024-09-26 at 10 11 24 and less layers is a Good Thing. ## Test Plan I hope the CI pipeline will take care of testing – I couldn't get the Docker build to finish on my machine right away (SIGKILL, so out of memory, I guess 😄) --- .github/workflows/build-docker.yml | 3 +-- Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 14936abd9..c4ce6a9cd 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -196,8 +196,7 @@ jobs: # Generate Dockerfile content cat < Dockerfile FROM ${BASE_IMAGE} - COPY --from=${{ env.UV_BASE_IMG }}:latest /uv /usr/local/bin/uv - COPY --from=${{ env.UV_BASE_IMG }}:latest /uvx /usr/local/bin/uvx + COPY --from=${{ env.UV_BASE_IMG }}:latest /uv /uvx /usr/local/bin/ ENTRYPOINT [] CMD ["/usr/local/bin/uv"] EOF diff --git a/Dockerfile b/Dockerfile index 2a4622296..d6aa98385 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,6 @@ RUN cp target/$(cat rust_target.txt)/release/uv /uv \ # RUN strip --strip-all /uv FROM scratch -COPY --from=build /uv /uv -COPY --from=build /uvx /uvx +COPY --from=build /uv /uvx / WORKDIR /io ENTRYPOINT ["/uv"]