From 9835dc4e076dd22c1bde8a4fe7cc532ae1cc3ebd Mon Sep 17 00:00:00 2001 From: morgan fainberg Date: Mon, 23 Feb 2026 15:26:09 -0800 Subject: [PATCH] fix: install uv via Docker COPY instead of curl pipe-to-shell Replace the fragile curl-based uv installer with COPY --from=ghcr.io/astral-sh/uv, which is the Docker-native approach recommended by astral. This fixes 'uv: not found' errors caused by stale Docker layer cache from the curl install step. Extract UVVersion constant so there is a single place to bump the version. --- pkg/dockerfile/standard_generator.go | 3 ++- pkg/dockerfile/standard_generator_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/dockerfile/standard_generator.go b/pkg/dockerfile/standard_generator.go index 65a177233c..50f1244548 100644 --- a/pkg/dockerfile/standard_generator.go +++ b/pkg/dockerfile/standard_generator.go @@ -44,6 +44,7 @@ coverage.xml const LDConfigCacheBuildCommand = "RUN find / -type f -name \"*python*.so\" -printf \"%h\\n\" | sort -u > /etc/ld.so.conf.d/cog.conf && ldconfig" const StripDebugSymbolsCommand = "find / -type f -name \"*python*.so\" -not -name \"*cpython*.so\" -exec strip -S {} \\;" const CFlags = "ENV CFLAGS=\"-O3 -funroll-loops -fno-strict-aliasing -flto -S\"" +const UVVersion = "0.9.26" const uvCacheMount = "--mount=type=cache,target=/root/.cache/uv" const uvPip = "uv pip" const PrecompilePythonCommand = "RUN find / -type f -name \"*.py[co]\" -delete && find / -type f -name \"*.py\" -exec touch -t 197001010000 {} \\; && find / -type f -name \"*.py\" -printf \"%h\\n\" | sort -u | /usr/bin/python3 -m compileall --invalidation-mode timestamp -o 2 -j 0" @@ -436,7 +437,7 @@ func (g *StandardGenerator) installPython() (string, error) { } func (g *StandardGenerator) installUV() string { - return `RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 UV_VERSION=0.9.26 sh + return `COPY --from=ghcr.io/astral-sh/uv:` + UVVersion + ` /uv /uvx /usr/local/bin/ ENV UV_SYSTEM_PYTHON=true` } diff --git a/pkg/dockerfile/standard_generator_test.go b/pkg/dockerfile/standard_generator_test.go index 2a3d0c604d..e7402a22b6 100644 --- a/pkg/dockerfile/standard_generator_test.go +++ b/pkg/dockerfile/standard_generator_test.go @@ -29,7 +29,7 @@ ENTRYPOINT ["/sbin/tini", "--"] ` } -const testInstallUVLine = "RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 UV_VERSION=0.9.26 sh\nENV UV_SYSTEM_PYTHON=true" +var testInstallUVLine = "COPY --from=ghcr.io/astral-sh/uv:" + UVVersion + " /uv /uvx /usr/local/bin/\nENV UV_SYSTEM_PYTHON=true" func testInstallCog(stripped bool) string { strippedCall := "" @@ -60,7 +60,7 @@ func testInstallPython(version string) string { git \ ca-certificates \ && rm -rf /var/lib/apt/lists/* -RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 UV_VERSION=0.9.26 sh +COPY --from=ghcr.io/astral-sh/uv:`+UVVersion+` /uv /uvx /usr/local/bin/ ENV UV_SYSTEM_PYTHON=true RUN uv python install %s && \ ln -sf $(uv python find %s) /usr/bin/python3