From e0f70a97cc14883b264b288c4c51afee4652b366 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Tue, 17 Jun 2025 17:29:19 +0100 Subject: [PATCH] use cargo-chef for compute-tools --- compute/compute-node.Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/compute/compute-node.Dockerfile b/compute/compute-node.Dockerfile index 248f52088b..e1354e872b 100644 --- a/compute/compute-node.Dockerfile +++ b/compute/compute-node.Dockerfile @@ -1722,11 +1722,29 @@ FROM extensions-${EXTENSIONS} AS neon-pg-ext-build # Compile the Neon-specific `compute_ctl`, `fast_import`, and `local_proxy` binaries # ######################################################################################### +FROM $REPOSITORY/$IMAGE:$TAG AS compute-tools-plan +ARG BUILD_TAG +ENV BUILD_TAG=$BUILD_TAG + +WORKDIR /home/nonroot +USER nonroot + +# Copy entire project to get Cargo.* files with proper dependencies for the whole project +COPY --chown=nonroot . . +RUN cargo chef prepare --recipe-path recipe.json + FROM $REPOSITORY/$IMAGE:$TAG AS compute-tools ARG BUILD_TAG ENV BUILD_TAG=$BUILD_TAG USER nonroot + +COPY --from=compute-tools-plan /home/nonroot/recipe.json recipe.json +RUN --mount=type=cache,uid=1000,target=/home/nonroot/.cargo/registry \ + --mount=type=cache,uid=1000,target=/home/nonroot/.cargo/git \ + --mount=type=cache,uid=1000,target=/home/nonroot/target \ + mold -run cargo chef cook --locked --profile release-line-debug-size-lto --recipe-path recipe.json + # Copy entire project to get Cargo.* files with proper dependencies for the whole project COPY --chown=nonroot . . RUN --mount=type=cache,uid=1000,target=/home/nonroot/.cargo/registry \