From 66441e763e10e14b7f3f9fd7ed9f1744e6a270cc Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 10:01:35 +0100 Subject: [PATCH] build: Dockerfile: Cleanup cargo registry at the end Cleaning up the cargo registry so that it can be used in the container should be done towards the end of the Dockerfile allowing more Rust tools be to used. Signed-off-by: Rob Bradford --- resources/Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/resources/Dockerfile b/resources/Dockerfile index 8379c9b3f..9c442ba2f 100644 --- a/resources/Dockerfile +++ b/resources/Dockerfile @@ -112,11 +112,7 @@ RUN export ARCH="$(uname -m)" \ $RUST_TOOLCHAIN-x86_64-unknown-linux-musl; fi \ && if [ "$TARGETARCH" = "amd64" ]; then rustup component add rustfmt; fi \ && if [ "$TARGETARCH" = "amd64" ]; then rustup component add clippy; fi \ - && cargo install cargo-nextest --locked --version 0.9.128 \ - && rm -rf "$CARGO_HOME/registry" \ - && ln -s "$CARGO_REGISTRY_DIR" "$CARGO_HOME/registry" \ - && rm -rf "$CARGO_HOME/git" \ - && ln -s "$CARGO_GIT_REGISTRY_DIR" "$CARGO_HOME/git" + && cargo install cargo-nextest --locked --version 0.9.128 # Set the rust environment # hadolint ignore=SC2016 @@ -150,6 +146,13 @@ RUN rm /usr/lib/python3.12/EXTERNALLY-MANAGED \ && cp -rf ./python /usr/local/bin \ && cd .. && rm -rf spdk +# Replace the cargo registry and git dirs with symlinks to the host bind-mount +# paths so that crate downloads are persisted across container invocations. +RUN rm -rf "$CARGO_HOME/registry" \ + && ln -s "$CARGO_REGISTRY_DIR" "$CARGO_HOME/registry" \ + && rm -rf "$CARGO_HOME/git" \ + && ln -s "$CARGO_GIT_REGISTRY_DIR" "$CARGO_HOME/git" + # install ethr tool for performance tests RUN if [ "$TARGETARCH" = "amd64" ]; then \ wget -nv https://github.com/microsoft/ethr/releases/latest/download/ethr_linux.zip \