From 191c0c756fb97d90890d96629309bec95217e225 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 21 Jul 2023 23:14:12 -0700 Subject: [PATCH] try binstall and sccache we tried binstall in the past and it had issues on arm, but now my laptop is arm and it works so i think whatever that was is fixed sccache should also make things faster (especially if we eventually add remote caches --- Dockerfile | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 791bd333..6b2b2a12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,18 +42,41 @@ RUN --mount=type=cache,target=/root/.cargo/git \ \ cargo check || [ "$?" -eq 101 ] -# nextest runs tests in parallel (done its in own FROM so that it can run in parallel) -FROM rust as rust_nextest +# cargo binstall +RUN --mount=type=cache,target=/root/.cargo/git \ + --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ + set -eux; \ + \ + curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh >/tmp/install-binstall.sh; \ + bash /tmp/install-binstall.sh; \ + rm -rf /tmp/* + +# sccache RUN --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ set -eux; \ \ - cargo install --locked cargo-nextest + cargo binstall -y sccache + +# TODO: full path +ENV RUSTC_WRAPPER "/root/.cargo/bin/sccache" + +# nextest runs tests in parallel (done its in own FROM so that it can run in parallel) +# TODO: i'd like to use binaries for these, but i had trouble with arm and binstall +FROM rust as rust_nextest +RUN --mount=type=cache,target=/root/.cargo/git \ + --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ + set -eux; \ + \ + cargo binstall -y cargo-nextest # foundry/anvil are needed to run tests (done its in own FROM so that it can run in parallel) FROM rust as rust_foundry RUN --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ set -eux; \ \ curl -L https://foundry.paradigm.xyz | bash && foundryup @@ -69,6 +92,7 @@ COPY . . # fetch deps RUN --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ --mount=type=cache,target=/app/target \ set -eux; \ \ @@ -84,6 +108,7 @@ COPY --from=rust_nextest /root/.cargo/bin/cargo-nextest* /root/.cargo/bin/ # test the application with cargo-nextest RUN --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ --mount=type=cache,target=/app/target \ set -eux; \ \ @@ -105,6 +130,7 @@ FROM rust_with_env as build_app # # TODO: use the "faster_release" profile which builds with `codegen-units = 1` (but compile is SLOW) RUN --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ --mount=type=cache,target=/app/target \ set -eux; \ \