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
This commit is contained in:
Bryan Stitt 2023-07-21 23:14:12 -07:00
parent df027527e9
commit 191c0c756f

View File

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