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 <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-05-27 10:01:35 +01:00
parent 29f392f8d4
commit 66441e763e

View File

@@ -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 \