From ad385fe148d12f48338cb0a70608be56b575e940 Mon Sep 17 00:00:00 2001 From: Zoritle <66551926+zoritle@users.noreply.github.com> Date: Fri, 6 Aug 2021 14:01:16 +0800 Subject: [PATCH 1/2] add sccache --- Dockerfile | 6 +++++- cargo-config.toml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d51dc9..f4e4467 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ ARG CARGO_ABOUT_VERSION=0.2.3 ARG CARGO_DENY_VERSION=0.8.5 ARG ZLIB_VERSION=1.2.11 ARG POSTGRESQL_VERSION=11.11 - +ARG SCCACHE_VERSION=0.2.15 # Make sure we have basic dev tools for building C libraries. Our goal here is # to support the musl-libc builds and Cargo builds needed for a large selection # of the most popular crates. @@ -61,6 +61,10 @@ RUN apt-get update && \ tar xf mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \ mv mdbook /usr/local/bin/ && \ rm -f mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \ + curl -fLO https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz && \ + tar xf sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz && \ + mv sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl/sccache /usr/local/bin/ && chmod +x /usr/local/bin/sccache && \ + rm -rf sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl && \ curl -fLO https://github.com/EmbarkStudios/cargo-about/releases/download/$CARGO_ABOUT_VERSION/cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz && \ tar xf cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz && \ mv cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl/cargo-about /usr/local/bin/ && \ diff --git a/cargo-config.toml b/cargo-config.toml index 848fe3a..f0e59c4 100644 --- a/cargo-config.toml +++ b/cargo-config.toml @@ -1,6 +1,6 @@ [build] # Target musl-libc by default when running Cargo. target = "x86_64-unknown-linux-musl" - +rustc-wrapper = "sccache" [target.armv7-unknown-linux-musleabihf] linker = "arm-linux-gnueabihf-gcc" From cffdaf940ae9e87627dd7534c796947a8fa519ae Mon Sep 17 00:00:00 2001 From: Zoritle <66551926+zoritle@users.noreply.github.com> Date: Fri, 6 Aug 2021 14:38:31 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eba05a6..928b3b4 100644 --- a/README.md +++ b/README.md @@ -54,14 +54,14 @@ You may be able to speed up build performance by adding the following `-v` comma ```txt -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry --v target:/home/rust/src/target +-v sccache:/home/rust/.cache/sccache ``` You will also need to fix the permissions on the mounted volumes: ```sh rust-musl-builder sudo chown -R rust:rust \ - /home/rust/.cargo/git /home/rust/.cargo/registry /home/rust/src/target + /home/rust/.cargo/git /home/rust/.cargo/registry /home/rust/.cache/sccache ``` ## How it works