From 1dd90340ce6c9633071b4c412d3bfca4d00fdc92 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 20 Sep 2023 13:48:10 -0700 Subject: [PATCH] move the rm to a spot that it can stay i think this will work. the target dirs should only be cleared if rust-toolchain.toml changes it will also clear target if a few other things change, but thats probably better than dealing with breaks every time we change the rust version --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 88acdc8c..e31af4bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,12 +39,16 @@ RUN --mount=type=cache,target=/root/.cargo/git \ # run a cargo command to install our desired version of rust # it is expected to exit code 101 since no Cargo.toml exists +# the rm is there because `cargo clean` can't run without a Cargo.toml, but a new version of rust likely needs a clean target dir COPY rust-toolchain.toml ./ RUN --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/app/target \ + --mount=type=cache,target=/app/target_test \ set -eux -o pipefail; \ \ - cargo check || [ "$?" -eq 101 ] + cargo check || [ "$?" -eq 101 ]; \ + rm -rf /app/target/* /app/target_test/* # cargo binstall RUN --mount=type=cache,target=/root/.cargo/git \