diff --git a/.github/actions/docker/action.yaml b/.github/actions/docker/action.yaml index c3ccf451bf6..c8cb6dc9a74 100644 --- a/.github/actions/docker/action.yaml +++ b/.github/actions/docker/action.yaml @@ -27,9 +27,6 @@ inputs: runs: using: composite steps: - - name: Setup sccache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Set up QEMU uses: docker/setup-qemu-action@master with: @@ -95,9 +92,6 @@ runs: tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} build-args: | - SCCACHE_GHA_ENABLED=true - ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }} - ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} CARGO_BUILD_PROFILE=dev platforms: ${{ env.build_platforms }} push: ${{ inputs.push }} diff --git a/.github/actions/rust/action.yaml b/.github/actions/rust/action.yaml index 8fac7eb2e81..c3500326a60 100644 --- a/.github/actions/rust/action.yaml +++ b/.github/actions/rust/action.yaml @@ -32,19 +32,10 @@ runs: echo "PROTOC=${HOME}/.local/bin/protoc" >> $GITHUB_ENV export PATH="${PATH}:${HOME}/.local/bin" - - name: Install sccache cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Set sccache Rust variables - shell: bash - run: | - echo SCCACHE_GHA_ENABLED=true >> $GITHUB_ENV - echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV - - name: Rust cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo diff --git a/.github/workflows/all-packages.yml b/.github/workflows/all-packages.yml index 0dfe349b2b7..b51297f6648 100644 --- a/.github/workflows/all-packages.yml +++ b/.github/workflows/all-packages.yml @@ -66,10 +66,6 @@ jobs: name: Run Platform Test Suite runs-on: self-hosted timeout-minutes: 30 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -94,16 +90,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Enable corepack run: corepack enable @@ -160,10 +150,6 @@ jobs: name: Run Platform Test Suite in Browsers runs-on: self-hosted timeout-minutes: 30 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Login to DockerHub uses: docker/login-action@v2 @@ -188,16 +174,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Enable corepack run: corepack enable @@ -287,16 +267,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Enable corepack run: corepack enable diff --git a/.github/workflows/js-checks.yml b/.github/workflows/js-checks.yml index 9e0a9520f04..821be51d344 100644 --- a/.github/workflows/js-checks.yml +++ b/.github/workflows/js-checks.yml @@ -28,10 +28,6 @@ jobs: name: Linting runs-on: self-hosted timeout-minutes: 15 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -56,16 +52,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Enable corepack run: corepack enable @@ -94,10 +84,6 @@ jobs: runs-on: self-hosted timeout-minutes: 30 if: ${{ !inputs.skip-tests }} - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Setup Firefox uses: browser-actions/setup-firefox@latest @@ -128,16 +114,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Enable corepack run: corepack enable diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 981960435a4..3411ea5d547 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,10 +20,6 @@ jobs: runs-on: self-hosted timeout-minutes: 15 if: github.event_name != 'workflow_dispatch' - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -42,16 +38,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -114,10 +104,6 @@ jobs: name: Release Drive to Docker Hub runs-on: self-hosted timeout-minutes: 120 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -137,16 +123,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -243,10 +223,6 @@ jobs: push: true tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} - build-args: | - SCCACHE_GHA_ENABLED=true - ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }} - ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} CARGO_BUILD_PROFILE=release platforms: linux/amd64,linux/arm64 @@ -254,10 +230,6 @@ jobs: name: Release DAPI to Docker Hub runs-on: self-hosted timeout-minutes: 120 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -277,16 +249,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -386,25 +352,16 @@ jobs: labels: ${{ steps.docker_meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build-args: | - SCCACHE_GHA_ENABLED=true - ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }} - ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} CARGO_BUILD_PROFILE=release cache-from: | type=gha - # In practice, time spent preparing images is much lower than build. - # We minimize cached info to leave more space for sccache cache. cache-to: | - type=gha,mode=min + type=gha,mode=max release-test-suite-docker-image: name: Release Test Suite to Docker Hub runs-on: self-hosted timeout-minutes: 120 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -424,16 +381,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -533,16 +484,11 @@ jobs: labels: ${{ steps.docker_meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build-args: | - SCCACHE_GHA_ENABLED=true - ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }} - ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} CARGO_BUILD_PROFILE=release cache-from: | type=gha - # In practice, time spent preparing images is much lower than build. - # We minimize cached info to leave more space for sccache cache. cache-to: | - type=gha,mode=min + type=gha,mode=max release-envoy-docker-image: name: Release Envoy to Docker Hub @@ -617,10 +563,6 @@ jobs: name: Release Dashmate helper to Docker Hub runs-on: self-hosted timeout-minutes: 60 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -634,8 +576,7 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo @@ -645,11 +586,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -749,9 +685,6 @@ jobs: labels: ${{ steps.docker_meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build-args: | - SCCACHE_GHA_ENABLED=true - ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }} - ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} CARGO_BUILD_PROFILE=release release-dashmate: @@ -770,10 +703,6 @@ jobs: os: ubuntu-22.04 - package_type: macos os: macos-12 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -824,16 +753,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Enable corepack run: corepack enable diff --git a/.github/workflows/rs-checks.yml b/.github/workflows/rs-checks.yml index 0be2f2f3ee1..5cfd7e36243 100644 --- a/.github/workflows/rs-checks.yml +++ b/.github/workflows/rs-checks.yml @@ -13,10 +13,6 @@ jobs: name: Linting runs-on: self-hosted timeout-minutes: 15 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -30,16 +26,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -65,10 +55,6 @@ jobs: name: Compilation errors runs-on: self-hosted timeout-minutes: 15 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -82,26 +68,16 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - run: cargo check --package=${{ inputs.package }} test: name: Tests runs-on: self-hosted timeout-minutes: 15 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -115,15 +91,9 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Run tests run: cargo test --package=${{ inputs.package }} --all-features diff --git a/.github/workflows/rs-drive.yml b/.github/workflows/rs-drive.yml index 3e3ff1bc2d3..f28744e7bb7 100644 --- a/.github/workflows/rs-drive.yml +++ b/.github/workflows/rs-drive.yml @@ -26,10 +26,7 @@ jobs: name: Feature compilation errors runs-on: self-hosted timeout-minutes: 15 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" + steps: - name: Check out repo uses: actions/checkout@v3 @@ -43,16 +40,10 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - run: cargo check --package=drive --no-default-features --features=verify rs-checks: diff --git a/.github/workflows/wasm-dpp.yml b/.github/workflows/wasm-dpp.yml index 269eddf149f..69f40afb9e0 100644 --- a/.github/workflows/wasm-dpp.yml +++ b/.github/workflows/wasm-dpp.yml @@ -43,10 +43,6 @@ jobs: name: WASM compilation runs-on: self-hosted timeout-minutes: 15 - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -60,15 +56,9 @@ jobs: - name: Setup Cargo cache uses: Swatinem/rust-cache@v2 with: - # Don't cache ./target, as it takes tons of space, use sccache instead. - cache-targets: false + cache-targets: true # We set a shared key, as our cache is reusable between jobs shared-key: rust-cargo - - name: Setup Rust compilation cache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.4.1" - - name: Compile WASM run: cargo check --lib --target wasm32-unknown-unknown --package=wasm-dpp diff --git a/Dockerfile b/Dockerfile index 60109550f50..f419f9adf27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ # # This image is divided multiple parts: # - deps - includes all dependencies and some libraries +# - depssccache - deps image with sccache included +# - deps-bindgen-cli - includes wasm-bindgen-cli; built on top of either deps or deps-sccache # - sources - includes full source code # - build-* - actual build process of given image # - drive-abci, dashmate-helper, test-suite, dapi - final images @@ -11,8 +13,9 @@ # The following build arguments can be provided using --build-arg: # - CARGO_BUILD_PROFILE - set to `release` to build final binary, without debugging information # - NODE_ENV - node.js environment name to use to build the library -# - SCCACHE_GHA_ENABLED, ACTIONS_CACHE_URL, ACTIONS_RUNTIME_TOKEN - store sccache caches inside github actions -# - SCCACHE_MEMCACHED - set to memcache server URI (eg. tcp://172.17.0.1:11211) to enable sccache memcached backend +# - RUSTC_WRAPPER - set to `sccache` to enable sccache support and make the following variables avaialable: +# - SCCACHE_GHA_ENABLED, ACTIONS_CACHE_URL, ACTIONS_RUNTIME_TOKEN - store sccache caches inside github actions +# - SCCACHE_MEMCACHED - set to memcache server URI (eg. tcp://172.17.0.1:11211) to enable sccache memcached backend # - ALPINE_VERSION - use different version of Alpine base image; requires also rust:apline... # image to be available # - USERNAME, USER_UID, USER_GID - specification of user used to run the binary @@ -28,6 +31,9 @@ ARG ALPINE_VERSION=3.16 +# Set RUSTC_WRAPPER to `sccache` to enable sccache caching +ARG RUSTC_WRAPPER + # # DEPS: INSTALL AND CACHE DEPENDENCIES # @@ -73,13 +79,6 @@ RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export PROTOC_ARCH=aarch_64; else e rm /tmp/protoc.zip && \ ln -s /opt/protoc/bin/protoc /usr/bin/ -# Install sccache for caching -RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export SCC_ARCH=aarch64; else export SCC_ARCH=x86_64; fi; \ - curl -Ls \ - https://github.com/mozilla/sccache/releases/download/v0.4.1/sccache-v0.4.1-${SCC_ARCH}-unknown-linux-musl.tar.gz | \ - tar -C /tmp -xz && \ - mv /tmp/sccache-*/sccache /usr/bin/ - # Configure Node.js RUN npm install -g npm@9.6.6 && \ npm install -g corepack@latest && \ @@ -89,11 +88,28 @@ RUN npm install -g npm@9.6.6 && \ # Switch to clang RUN rm /usr/bin/cc && ln -s /usr/bin/clang /usr/bin/cc + +# Select whether we want dev or release +ARG CARGO_BUILD_PROFILE=dev +ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} + +ARG NODE_ENV=production +ENV NODE_ENV ${NODE_ENV} + +ARG RUSTC_WRAPPER + +FROM deps AS depssccache + +# Install sccache for caching +RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export SCC_ARCH=aarch64; else export SCC_ARCH=x86_64; fi; \ + curl -Ls \ + https://github.com/mozilla/sccache/releases/download/v0.4.1/sccache-v0.4.1-${SCC_ARCH}-unknown-linux-musl.tar.gz | \ + tar -C /tmp -xz && \ + mv /tmp/sccache-*/sccache /usr/bin/ + # # Configure sccache # -# Activate sccache for Rust code -ENV RUSTC_WRAPPER=/usr/bin/sccache # Set args below to use Github Actions cache; see https://github.com/mozilla/sccache/blob/main/docs/GHA.md ARG SCCACHE_GHA_ENABLED ARG ACTIONS_CACHE_URL @@ -104,12 +120,11 @@ ARG SCCACHE_MEMCACHED # Disable incremental buildings, not supported by sccache ARG CARGO_INCREMENTAL=false -# Select whether we want dev or release -ARG CARGO_BUILD_PROFILE=dev -ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} - -ARG NODE_ENV=production -ENV NODE_ENV ${NODE_ENV} +# +# DEPS-BINDGEN-CLI: ADD DEPS-BINDGEN-CLI TOOL +# +# This is separate from `deps` to use sccache for caching +FROM deps${RUSTC_WRAPPER} AS deps-bindgen-cli # Install wasm-bindgen-cli in the same profile as other components, to sacrifice some performance & disk space to gain # better build caching @@ -126,7 +141,7 @@ RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ # # LOAD SOURCES # -FROM deps as sources +FROM deps-bindgen-cli as sources WORKDIR /platform @@ -156,7 +171,8 @@ RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ -p drive-abci \ --config net.git-fetch-with-cli=true && \ cp /platform/target/*/drive-abci /artifacts/drive-abci && \ - sccache --show-stats + if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi + # # STAGE: BUILD JAVASCRIPT INTERMEDIATE IMAGE @@ -178,7 +194,7 @@ RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ yarn install && \ yarn build && \ cp -R /platform/.yarn/unplugged /tmp/ && \ - sccache --show-stats + if [[ "${RUSTC_WRAPPER}" == "sccache" ]]; then sccache --show-stats; fi # # STAGE: FINAL DRIVE-ABCI IMAGE diff --git a/docs/DOCKER.md b/docs/DOCKER.md index 1aa93d5a7e8..0452ae11ca8 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -65,10 +65,20 @@ GC Policy rule#0: ### Sccache -[Sccache](https://github.com/mozilla/sccache) is an additional layer of caching that can be used to improve build speed. Sccache can cache build artifacts using multiple storage systems, like localfilesystem, Github Actions, S3 buckets, memcache, and others. +[Sccache](https://github.com/mozilla/sccache) is an additional layer of caching that can be used to improve build speed. Sccache can cache build artifacts using multiple storage systems, like local filesystem, Github Actions, S3 buckets, memcache, and others. For local development in Docker, sccache uses Docker cache mounts. Alternative solution can be to use memcached daemon for caching. +Sccache is disabled by default. + +#### Enabling sccache + +To enable sccache, set `RUSTC_WRAPPER=sccache` build argument when building the Docker image. For example: + +```bash +docker buildx build --build-arg RUSTC_WRAPPER=sccache --target drive-abci . +``` + #### Sccache and memcached To use sccache with memcache, setup local memcached daemon with reasonable amount of RAM (4GB here): @@ -82,9 +92,10 @@ Replace `172.17.0.1` with IP address of the host running memcached accessible fr ##### Using memcache with Dashmate -To use sccache an Before starting dashmate build, set `SCCACHE_MEMCACHED` to address of your memcache server: +Before starting dashmate build, set `SCCACHE_MEMCACHED` to address of your memcache server: ```bash +export RUSTC_WRAPPER=sccache export SCCACHE_MEMCACHED=tcp://172.17.0.1:11211 ``` diff --git a/packages/dashmate/docker-compose.platform.build.yml b/packages/dashmate/docker-compose.platform.build.yml index b4964dc7bbe..3e3166f8d23 100644 --- a/packages/dashmate/docker-compose.platform.build.yml +++ b/packages/dashmate/docker-compose.platform.build.yml @@ -7,6 +7,7 @@ services: dockerfile: ${PLATFORM_SOURCE_PATH:?err}/Dockerfile target: drive-abci args: + RUSTC_WRAPPER: "${RUSTC_WRAPPER}" SCCACHE_MEMCACHED: ${SCCACHE_MEMCACHED} SCCACHE_GHA_ENABLED: ${SCCACHE_GHA_ENABLED} ACTIONS_CACHE_URL: ${ACTIONS_CACHE_URL} @@ -20,6 +21,7 @@ services: dockerfile: ${PLATFORM_SOURCE_PATH:?err}/Dockerfile target: dapi args: + RUSTC_WRAPPER: "${RUSTC_WRAPPER}" SCCACHE_MEMCACHED: ${SCCACHE_MEMCACHED} SCCACHE_GHA_ENABLED: ${SCCACHE_GHA_ENABLED} ACTIONS_CACHE_URL: ${ACTIONS_CACHE_URL} @@ -33,6 +35,7 @@ services: dockerfile: ${PLATFORM_SOURCE_PATH:?err}/Dockerfile target: dapi args: + RUSTC_WRAPPER: "${RUSTC_WRAPPER}" SCCACHE_MEMCACHED: ${SCCACHE_MEMCACHED} SCCACHE_GHA_ENABLED: ${SCCACHE_GHA_ENABLED} ACTIONS_CACHE_URL: ${ACTIONS_CACHE_URL} @@ -45,6 +48,7 @@ services: context: ${PLATFORM_SOURCE_PATH:?err} dockerfile: ${PLATFORM_SOURCE_PATH:?err}/packages/dashmate/docker/envoy/Dockerfile args: + RUSTC_WRAPPER: "${RUSTC_WRAPPER}" SCCACHE_MEMCACHED: ${SCCACHE_MEMCACHED} SCCACHE_GHA_ENABLED: ${SCCACHE_GHA_ENABLED} ACTIONS_CACHE_URL: ${ACTIONS_CACHE_URL} @@ -58,6 +62,7 @@ services: dockerfile: ${PLATFORM_SOURCE_PATH:?err}/Dockerfile target: dashmate-helper args: + RUSTC_WRAPPER: "${RUSTC_WRAPPER}" SCCACHE_MEMCACHED: ${SCCACHE_MEMCACHED} SCCACHE_GHA_ENABLED: ${SCCACHE_GHA_ENABLED} ACTIONS_CACHE_URL: ${ACTIONS_CACHE_URL}