diff --git a/.github/workflows/all-packages.yml b/.github/workflows/all-packages.yml index 47962f1b3ce..01db2da1d29 100644 --- a/.github/workflows/all-packages.yml +++ b/.github/workflows/all-packages.yml @@ -64,12 +64,22 @@ jobs: test-suite: name: Run Platform Test Suite - runs-on: ubuntu-22.04 - timeout-minutes: 60 + runs-on: self-hosted # ubuntu-22.04 + timeout-minutes: 30 + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -81,27 +91,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup Cargo cache + uses: Swatinem/rust-cache@v2 with: - version: "v0.4.1" - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" + # Don't cache ./target, as it takes tons of space, use sccache instead. + cache-targets: false + # We set a shared key, as our cache is reusable between jobs + shared-key: rust-cargo - - name: Configure sccache - uses: actions/github-script@v6 + - name: Setup Rust compilation cache + uses: mozilla-actions/sccache-action@v0.0.3 with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - - name: Run sccache stat for check - shell: bash - run: ${SCCACHE_PATH} --show-stats - - # - name: Enable Rust cache - # uses: Swatinem/rust-cache@v2 + version: "v0.4.1" - name: Enable corepack run: corepack enable @@ -125,26 +126,22 @@ jobs: - name: Set up Docker BuildX id: buildx - uses: docker/setup-buildx-action@v2.5.0 + uses: docker/setup-buildx-action@v2 + + - name: Enable docker cache mount + uses: actions/cache@v3 + with: + path: /tmp/buildkit-cache/buildkit-state.tar + key: ${{ runner.os }}-buildkit-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildkit + + - name: Load docker cache mount + uses: dashevo/gh-action-cache-buildkit-state@v1 with: - version: v0.10.4 - install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - # - name: Enable buildkit cache - # uses: actions/cache@v3 - # with: - # path: /tmp/buildkit-cache/buildkit-state.tar - # key: ${{ runner.os }}-buildkit-${{ github.sha }} - # restore-keys: | - # ${{ runner.os }}-buildkit- - - # - name: Load buildkit state from cache - # uses: dashevo/gh-action-cache-buildkit-state@skip-cachemount - # with: - # builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 - # cache-path: /tmp/buildkit-cache - # cache-max-size: 6gb + builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 + cache-path: /tmp/buildkit-cache + cache-max-size: 3g - name: Setup local network run: yarn configure @@ -161,9 +158,19 @@ jobs: test-suite-browsers: name: Run Platform Test Suite in Browsers - runs-on: ubuntu-22.04 - timeout-minutes: 60 + runs-on: self-hosted # ubuntu-22.04 + timeout-minutes: 30 + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Check out repo uses: actions/checkout@v3 @@ -178,8 +185,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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 @@ -204,25 +221,21 @@ jobs: - name: Set up Docker BuildX id: buildx uses: docker/setup-buildx-action@v2 - with: - version: v0.9.1 - install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - name: Enable buildkit cache + - name: Enable docker cache mount uses: actions/cache@v3 with: path: /tmp/buildkit-cache/buildkit-state.tar key: ${{ runner.os }}-buildkit-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildkit- + ${{ runner.os }}-buildkit - - name: Load buildkit state from cache - uses: dashevo/gh-action-cache-buildkit-state@skip-cachemount + - name: Load docker cache mount + uses: dashevo/gh-action-cache-buildkit-state@v1 with: builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 cache-path: /tmp/buildkit-cache - cache-max-size: 6gb + cache-max-size: 3g - name: Setup local network run: yarn configure @@ -248,6 +261,12 @@ jobs: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -264,10 +283,19 @@ jobs: with: toolchain: stable target: wasm32-unknown-unknown - components: clippy - - name: Setup wasm-bindgen - run: cargo install -f wasm-bindgen-cli + - 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 + # 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,14 +315,7 @@ jobs: run: yarn install - name: Build package and dependencies - run: yarn build --filter "+${{ inputs.package }}" - if: ${{ !inputs.start-local-network }} - - - name: Build all packages - run: yarn build - if: ${{ inputs.start-local-network }} + run: yarn build --filter "+dash" - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 - with: - category: "/language:javascript" diff --git a/.github/workflows/dapi-grpc.yml b/.github/workflows/dapi-grpc.yml index d95ab52480e..010d8e1987d 100644 --- a/.github/workflows/dapi-grpc.yml +++ b/.github/workflows/dapi-grpc.yml @@ -24,3 +24,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/dapi-grpc' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dapi.yml b/.github/workflows/dapi.yml index 5b69d026a05..c2066d51ef2 100644 --- a/.github/workflows/dapi.yml +++ b/.github/workflows/dapi.yml @@ -34,3 +34,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/dapi' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dash-spv.yml b/.github/workflows/dash-spv.yml index 87882ab9aec..1585d0b1b87 100644 --- a/.github/workflows/dash-spv.yml +++ b/.github/workflows/dash-spv.yml @@ -23,3 +23,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/dash-spv' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dashmate.yml b/.github/workflows/dashmate.yml index 56ccba3a656..1596a256153 100644 --- a/.github/workflows/dashmate.yml +++ b/.github/workflows/dashmate.yml @@ -36,3 +36,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: 'dashmate' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dashpay-contract.yml b/.github/workflows/dashpay-contract.yml index 8eaae682be1..88c6a4f36af 100644 --- a/.github/workflows/dashpay-contract.yml +++ b/.github/workflows/dashpay-contract.yml @@ -28,3 +28,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/dashpay-contract' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/js-checks.yml b/.github/workflows/js-checks.yml index 76c685fe8fb..72a6dc99cc8 100644 --- a/.github/workflows/js-checks.yml +++ b/.github/workflows/js-checks.yml @@ -22,16 +22,34 @@ on: type: boolean default: false required: false + dockerhub-username: + description: DockerHub username + type: string + required: true + dockerhub-token: + description: DockerHub token + type: string + required: true jobs: lint: name: Linting - runs-on: ubuntu-22.04 - timeout-minutes: 20 + 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 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ inputs.dockerhub-username }} + password: ${{ inputs.dockerhub-token }} + - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -43,8 +61,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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 @@ -71,9 +99,13 @@ jobs: test: name: Tests - runs-on: ubuntu-22.04 - timeout-minutes: 60 + 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 @@ -84,6 +116,12 @@ jobs: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ inputs.dockerhub-username }} + password: ${{ inputs.dockerhub-token }} + - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -95,8 +133,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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 @@ -120,6 +168,7 @@ jobs: env: NODE_ENV: test + # TODO: We build second time here, but with cache it must be quick - name: Build SDK run: yarn build --filter "+dash" if: ${{ inputs.start-local-network }} @@ -133,28 +182,22 @@ jobs: - name: Set up Docker BuildX id: buildx uses: docker/setup-buildx-action@v2 - with: - version: v0.9.1 - install: true - driver-opts: image=moby/buildkit:buildx-stable-1 if: ${{ inputs.start-local-network }} - - name: Enable buildkit cache + - name: Enable docker cache mount uses: actions/cache@v3 with: path: /tmp/buildkit-cache/buildkit-state.tar key: ${{ runner.os }}-buildkit-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildkit- - if: ${{ inputs.start-local-network }} + ${{ runner.os }}-buildkit - - name: Load buildkit state from cache + - name: Load docker cache mount uses: dashevo/gh-action-cache-buildkit-state@v1 with: builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 cache-path: /tmp/buildkit-cache cache-max-size: 3g - if: ${{ inputs.start-local-network }} - name: Setup local network run: yarn configure diff --git a/.github/workflows/js-dapi-client.yml b/.github/workflows/js-dapi-client.yml index b1a8b3ed831..e14859d9cd6 100644 --- a/.github/workflows/js-dapi-client.yml +++ b/.github/workflows/js-dapi-client.yml @@ -32,3 +32,5 @@ jobs: with: package: '@dashevo/dapi-client' install-browsers: true + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/js-dash-sdk.yml b/.github/workflows/js-dash-sdk.yml index 60cb9a82e69..9ae6eb8614d 100644 --- a/.github/workflows/js-dash-sdk.yml +++ b/.github/workflows/js-dash-sdk.yml @@ -35,3 +35,5 @@ jobs: package: 'dash' start-local-network: true install-browsers: true + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/js-dpp.yml b/.github/workflows/js-dpp.yml index 064c87ff09f..64bd9eb5b10 100644 --- a/.github/workflows/js-dpp.yml +++ b/.github/workflows/js-dpp.yml @@ -28,3 +28,5 @@ jobs: with: package: '@dashevo/dpp' install-browsers: true + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/js-drive.yml b/.github/workflows/js-drive.yml index 3d850ad8ce7..c4f0782cd3e 100644 --- a/.github/workflows/js-drive.yml +++ b/.github/workflows/js-drive.yml @@ -31,3 +31,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/drive' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/js-grpc-common.yml b/.github/workflows/js-grpc-common.yml index 7541c43d273..ffc2ea10891 100644 --- a/.github/workflows/js-grpc-common.yml +++ b/.github/workflows/js-grpc-common.yml @@ -23,3 +23,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/grpc-common' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/platform-test-suite.yml b/.github/workflows/platform-test-suite.yml index 2c922afa115..4082f4c07a7 100644 --- a/.github/workflows/platform-test-suite.yml +++ b/.github/workflows/platform-test-suite.yml @@ -36,3 +36,5 @@ jobs: package: '@dashevo/platform-test-suite' skip-tests: true install-browsers: true + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95ccab5509a..2394438f313 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,10 +17,14 @@ concurrency: jobs: release-npm: name: Release NPM packages - runs-on: ubuntu-22.04 + runs-on: self-hosted if: github.event_name != 'workflow_dispatch' needs: - build-rs-drive-nodejs + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -36,8 +40,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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 @@ -105,11 +119,26 @@ jobs: release-drive-docker-image: name: Release Drive to Docker Hub - runs-on: ubuntu-22.04 + runs-on: self-hosted + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + 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: @@ -134,39 +163,32 @@ jobs: - name: Build packages run: yarn build --filter "+@dashevo/drive" + env: + CARGO_BUILD_PROFILE: release - name: Set up QEMU to run multi-arch builds uses: docker/setup-qemu-action@v2 - name: Set up Docker BuildX - id: buildx uses: docker/setup-buildx-action@v2 with: - version: v0.9.1 install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - name: Enable buildkit cache + - name: Enable docker cache mount uses: actions/cache@v3 with: path: /tmp/buildkit-cache/buildkit-state.tar key: ${{ runner.os }}-buildkit-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildkit- + ${{ runner.os }}-buildkit - - name: Load buildkit state from cache + - name: Load docker cache mount uses: dashevo/gh-action-cache-buildkit-state@v1 with: builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 cache-path: /tmp/buildkit-cache cache-max-size: 3g - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Get tag uses: actions/github-script@v6 id: tag @@ -212,15 +234,35 @@ 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 release-dapi-docker-image: name: Release DAPI to Docker Hub - runs-on: ubuntu-22.04 + runs-on: self-hosted + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + 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: @@ -245,6 +287,8 @@ jobs: - name: Build packages run: yarn build --filter "+@dashevo/dapi" + env: + CARGO_BUILD_PROFILE: release - name: Set up QEMU to run multi-arch builds uses: docker/setup-qemu-action@v2 @@ -253,31 +297,23 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 with: - version: v0.9.1 install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - name: Enable buildkit cache + - name: Enable docker cache mount uses: actions/cache@v3 with: path: /tmp/buildkit-cache/buildkit-state.tar key: ${{ runner.os }}-buildkit-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildkit- + ${{ runner.os }}-buildkit - - name: Load buildkit state from cache + - name: Load docker cache mount uses: dashevo/gh-action-cache-buildkit-state@v1 with: builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 cache-path: /tmp/buildkit-cache cache-max-size: 3g - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Get tag uses: actions/github-script@v6 id: tag @@ -324,14 +360,40 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} 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 release-test-suite-docker-image: name: Release Test Suite to Docker Hub - runs-on: ubuntu-22.04 + runs-on: self-hosted + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + 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: @@ -356,6 +418,8 @@ jobs: - name: Build packages run: yarn build --filter "+@dashevo/platform-test-suite" + env: + CARGO_BUILD_PROFILE: release - name: Set up QEMU to run multi-arch builds uses: docker/setup-qemu-action@v2 @@ -364,31 +428,23 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 with: - version: v0.9.1 install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - name: Enable buildkit cache + - name: Enable docker cache mount uses: actions/cache@v3 with: path: /tmp/buildkit-cache/buildkit-state.tar key: ${{ runner.os }}-buildkit-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildkit- + ${{ runner.os }}-buildkit - - name: Load buildkit state from cache + - name: Load docker cache mount uses: dashevo/gh-action-cache-buildkit-state@v1 with: builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 cache-path: /tmp/buildkit-cache cache-max-size: 3g - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Get tag uses: actions/github-script@v6 id: tag @@ -435,6 +491,17 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} 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 release-envoy-docker-image: name: Release Envoy to Docker Hub @@ -443,6 +510,12 @@ jobs: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up QEMU to run multi-arch builds uses: docker/setup-qemu-action@v2 @@ -450,30 +523,7 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 with: - version: v0.9.1 install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - - name: Enable buildkit cache - uses: actions/cache@v3 - with: - path: /tmp/buildkit-cache/buildkit-state.tar - key: ${{ runner.os }}-buildkit-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildkit- - - - name: Load buildkit state from cache - uses: dashevo/gh-action-cache-buildkit-state@v1 - with: - builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 - cache-path: /tmp/buildkit-cache - cache-max-size: 3g - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Get tag uses: actions/github-script@v6 @@ -521,16 +571,29 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} platforms: linux/amd64,linux/arm64 - build-args: | - CARGO_BUILD_PROFILE=release release-dashmate-helper-docker-image: name: Release Dashmate helper to Docker Hub - runs-on: ubuntu-22.04 + runs-on: self-hosted + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + 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: @@ -555,6 +618,8 @@ jobs: - name: Build packages run: yarn build --filter "+dashmate" + env: + CARGO_BUILD_PROFILE: release - name: Set up QEMU to run multi-arch builds uses: docker/setup-qemu-action@v2 @@ -563,31 +628,23 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 with: - version: v0.9.1 install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - - name: Enable buildkit cache + - name: Enable docker cache mount uses: actions/cache@v3 with: path: /tmp/buildkit-cache/buildkit-state.tar key: ${{ runner.os }}-buildkit-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildkit- + ${{ runner.os }}-buildkit - - name: Load buildkit state from cache + - name: Load docker cache mount uses: dashevo/gh-action-cache-buildkit-state@v1 with: builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 cache-path: /tmp/buildkit-cache cache-max-size: 3g - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Get tag uses: actions/github-script@v6 id: tag @@ -634,7 +691,13 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} 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 + # TODO: Implement yarn and rust cache build-rs-drive-nodejs: name: Build Drive Node.JS binding strategy: @@ -670,10 +733,20 @@ jobs: platform: apple-darwin runs-on: ${{ matrix.os }} + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup Node.JS uses: actions/setup-node@v3 with: @@ -719,8 +792,19 @@ jobs: toolchain: stable target: ${{ steps.set-target.outputs.result }} - - name: Enable Rust cache + - 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 + # We set a shared key, as our cache is reusable between jobs + shared-key: rust-cargo + + - name: Setup Rust compilation cache + if: ${{ runner.os == 'macOS' }} + uses: mozilla-actions/sccache-action@v0.0.3 + with: + version: "v0.4.1" - name: Set LIBC argument uses: actions/github-script@v6 @@ -784,15 +868,14 @@ 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 - - name: Setup Node.JS - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: Install macOS build deps if: runner.os == 'macOS' run: | @@ -827,11 +910,29 @@ jobs: if: runner.os == 'Linux' run: sudo apt-get install -y nsis + - name: Setup Node.JS + uses: actions/setup-node@v3 + with: + node-version: '16' + - uses: dtolnay/rust-toolchain@master with: toolchain: stable target: wasm32-unknown-unknown + - 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 + # 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 @@ -849,10 +950,9 @@ jobs: - name: Install dependencies run: yarn install + # TODO: We don't need to build it, since pack should use released npm packages - name: Build packages - run: yarn build - env: - CARGO_BUILD_PROFILE: release + run: yarn build --filter "+dashmate" - name: Create package env: diff --git a/.github/workflows/rs-checks.yml b/.github/workflows/rs-checks.yml index 50e379f7729..cd340ffde94 100644 --- a/.github/workflows/rs-checks.yml +++ b/.github/workflows/rs-checks.yml @@ -11,8 +11,12 @@ on: jobs: lint: name: Linting - runs-on: ubuntu-22.04 - timeout-minutes: 20 + 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 @@ -23,8 +27,18 @@ jobs: toolchain: stable components: clippy - - name: Enable Rust cache + - 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 + # 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: @@ -49,8 +63,12 @@ jobs: compile: name: Compilation errors - runs-on: ubuntu-22.04 - timeout-minutes: 20 + 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 @@ -61,15 +79,29 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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: ubuntu-22.04 - timeout-minutes: 20 + 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 @@ -80,8 +112,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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-nodejs.yml b/.github/workflows/rs-drive-nodejs.yml index 2f3a86c164b..9473c6439da 100644 --- a/.github/workflows/rs-drive-nodejs.yml +++ b/.github/workflows/rs-drive-nodejs.yml @@ -37,3 +37,5 @@ jobs: uses: ./.github/workflows/js-checks.yml with: package: '@dashevo/rs-drive' + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/rs-drive.yml b/.github/workflows/rs-drive.yml index a973f586e80..b1582a8460f 100644 --- a/.github/workflows/rs-drive.yml +++ b/.github/workflows/rs-drive.yml @@ -24,8 +24,12 @@ concurrency: jobs: feature-compilation: name: Feature compilation errors - runs-on: ubuntu-22.04 - timeout-minutes: 20 + 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 @@ -36,8 +40,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust Cache + - 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 + # 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 diff --git a/.github/workflows/wallet-lib.yml b/.github/workflows/wallet-lib.yml index 1a3d18735d6..a035506f538 100644 --- a/.github/workflows/wallet-lib.yml +++ b/.github/workflows/wallet-lib.yml @@ -34,3 +34,5 @@ jobs: package: '@dashevo/wallet-lib' start-local-network: true install-browsers: true + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/wasm-dpp.yml b/.github/workflows/wasm-dpp.yml index ef343d819a4..c4c528a2146 100644 --- a/.github/workflows/wasm-dpp.yml +++ b/.github/workflows/wasm-dpp.yml @@ -31,6 +31,8 @@ jobs: with: package: '@dashevo/wasm-dpp' install-browsers: true + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} rs-checks: name: Rust @@ -40,7 +42,11 @@ jobs: wasm-errors: name: WASM compilation - runs-on: ubuntu-22.04 + runs-on: self-hosted + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CARGO_INCREMENTAL: "false" steps: - name: Check out repo uses: actions/checkout@v3 @@ -51,8 +57,18 @@ jobs: toolchain: stable target: wasm32-unknown-unknown - - name: Enable Rust cache + - 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 + # 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/packages/dapi/Dockerfile b/packages/dapi/Dockerfile index c519569131d..1254519a369 100644 --- a/packages/dapi/Dockerfile +++ b/packages/dapi/Dockerfile @@ -1,5 +1,16 @@ # syntax = docker/dockerfile:1.5 -FROM strophy/buildbase:0.0.4 as builder +FROM strophy/buildbase:0.0.6 as builder + +# TODO: Probably should be release by default +ARG CARGO_BUILD_PROFILE=debug +ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} + +ARG NODE_ENV=production +ENV NODE_ENV ${NODE_ENV} + +ARG SCCACHE_GHA_ENABLED +ARG ACTIONS_CACHE_URL +ARG ACTIONS_RUNTIME_TOKEN WORKDIR /platform @@ -29,7 +40,7 @@ COPY packages/masternode-reward-shares-contract packages/masternode-reward-share COPY packages/feature-flags-contract packages/feature-flags-contract # Build WASM DPP -RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ +RUN --mount=type=cache,sharing=private,target=/root/.cache/sccache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \ @@ -45,10 +56,11 @@ RUN --mount=type=cache,target=/tmp/unplugged \ yarn workspaces focus --production @dashevo/dapi && \ cp -R /platform/.yarn/unplugged /tmp/ -FROM node:16-alpine3.16 -ARG NODE_ENV=production -ENV NODE_ENV ${NODE_ENV} +# Remove Rust sources +RUN rm -rf packages/rs-dpp packages/rs-platform-value + +FROM node:16-alpine3.16 LABEL maintainer="Dash Developers " LABEL description="DAPI Node.JS" @@ -60,9 +72,6 @@ WORKDIR /platform COPY --from=builder /platform /platform -# Remove Rust sources -RUN rm -rf packages/rs-dpp packages/rs-platform-value - RUN cp /platform/packages/dapi/.env.example /platform/packages/dapi/.env EXPOSE 2500 2501 2510 diff --git a/packages/dashmate/Dockerfile b/packages/dashmate/Dockerfile index 19f7ede63a4..17b411da013 100644 --- a/packages/dashmate/Dockerfile +++ b/packages/dashmate/Dockerfile @@ -1,5 +1,16 @@ # syntax = docker/dockerfile:1.5 -FROM strophy/buildbase:0.0.4 as builder +FROM strophy/buildbase:0.0.6 as builder + +# TODO: Probably should be release by default +ARG CARGO_BUILD_PROFILE=debug +ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} + +ARG NODE_ENV=production +ENV NODE_ENV ${NODE_ENV} + +ARG SCCACHE_GHA_ENABLED +ARG ACTIONS_CACHE_URL +ARG ACTIONS_RUNTIME_TOKEN WORKDIR /platform @@ -33,7 +44,7 @@ COPY packages/rs-dpp packages/rs-dpp COPY packages/wasm-dpp packages/wasm-dpp # Build WASM DPP -RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ +RUN --mount=type=cache,sharing=private,target=/root/.cache/sccache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \ @@ -49,10 +60,10 @@ RUN --mount=type=cache,target=/tmp/unplugged \ yarn workspaces focus --production dashmate && \ cp -R /platform/.yarn/unplugged /tmp/ -FROM node:16-alpine3.16 +# Remove Rust sources +RUN rm -rf packages/rs-dpp packages/rs-platform-value -ARG NODE_ENV=production -ENV NODE_ENV ${NODE_ENV} +FROM node:16-alpine3.16 RUN apk update && \ apk --no-cache upgrade && \ @@ -65,7 +76,4 @@ WORKDIR /platform COPY --from=builder /platform /platform -# Remove Rust sources -RUN rm -rf packages/rs-dpp packages/rs-platform-value - ENTRYPOINT ["/platform/packages/dashmate/docker/entrypoint.sh"] diff --git a/packages/dashmate/docker/envoy/Dockerfile b/packages/dashmate/docker/envoy/Dockerfile index 5261e33568d..9bb17a1b0a9 100644 --- a/packages/dashmate/docker/envoy/Dockerfile +++ b/packages/dashmate/docker/envoy/Dockerfile @@ -1,7 +1,8 @@ FROM envoyproxy/envoy:v1.22-latest as builder RUN apt update && \ - apt -qq -y install python + apt -qq -y install python && \ + rm -rf /var/lib/apt/lists/* COPY packages/dashmate/docker/envoy/hot-restarter.py /etc/envoy/hot-restarter.py COPY packages/dashmate/docker/envoy/start_envoy.sh /etc/envoy/start_envoy.sh diff --git a/packages/dashmate/src/config/Config.js b/packages/dashmate/src/config/Config.js index 9fe370b28d0..27d1cff55e0 100644 --- a/packages/dashmate/src/config/Config.js +++ b/packages/dashmate/src/config/Config.js @@ -175,6 +175,7 @@ class Config { COMPOSE_FILE: dockerComposeFiles.join(':'), COMPOSE_PATH_SEPARATOR: ':', DOCKER_BUILDKIT: 1, + COMPOSE_DOCKER_CLI_BUILD: 1, ...convertObjectToEnvs(this.getOptions()), }; diff --git a/packages/dashmate/src/docker/DockerCompose.js b/packages/dashmate/src/docker/DockerCompose.js index a7d7438913a..cd4bfec98e3 100644 --- a/packages/dashmate/src/docker/DockerCompose.js +++ b/packages/dashmate/src/docker/DockerCompose.js @@ -122,6 +122,7 @@ class DockerCompose { * * @param {Object} envs * @param {string} [serviceName] + * @param {Array} [options] * @return {Observable<{string}>} */ // eslint-disable-next-line no-unused-vars @@ -144,6 +145,7 @@ class DockerCompose { await dockerCompose.buildAll({ ...this.getOptions(envs), callback, + commandOptions: options, }); } diff --git a/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js b/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js index 856b1b2ca48..9e0a586ff30 100644 --- a/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js @@ -19,7 +19,19 @@ function buildServicesTaskFactory( task: async (ctx, task) => { const envs = config.toEnvs(); - const obs = await dockerCompose.build(envs); + let buildArgs = []; + if (process.env.SCCACHE_GHA_ENABLED === 'true') { + buildArgs = buildArgs.concat([ + '--build-arg', + 'SCCACHE_GHA_ENABLED=true', + '--build-arg', + `ACTIONS_CACHE_URL=${process.env.ACTIONS_CACHE_URL}`, + '--build-arg', + `ACTIONS_RUNTIME_TOKEN=${process.env.ACTIONS_RUNTIME_TOKEN}`, + ]); + } + + const obs = await dockerCompose.build(envs, undefined, buildArgs); await new Promise((res, rej) => { obs diff --git a/packages/js-drive/Dockerfile b/packages/js-drive/Dockerfile index 88df6fa0c93..6f920044f68 100644 --- a/packages/js-drive/Dockerfile +++ b/packages/js-drive/Dockerfile @@ -1,5 +1,16 @@ # syntax = docker/dockerfile:1.5 -FROM strophy/buildbase:0.0.4 as builder +FROM strophy/buildbase:0.0.6 as builder + +# TODO: Probably should be release by default +ARG CARGO_BUILD_PROFILE=debug +ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} + +ARG NODE_ENV=production +ENV NODE_ENV ${NODE_ENV} + +ARG SCCACHE_GHA_ENABLED +ARG ACTIONS_CACHE_URL +ARG ACTIONS_RUNTIME_TOKEN WORKDIR /platform @@ -30,21 +41,13 @@ COPY packages/masternode-reward-shares-contract packages/masternode-reward-share COPY packages/withdrawals-contract packages/withdrawals-contract COPY packages/data-contracts packages/data-contracts -# Build RS Drive Node.JS binding -RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ +# Build RS Drive Node.JS binding and WASM DPP +RUN --mount=type=cache,sharing=private,target=/root/.cache/sccache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \ export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \ yarn workspace @dashevo/rs-drive build && \ - sccache --show-stats - -# Build WASM DPP -RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ - --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \ - --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \ - --mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \ - export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \ yarn workspace @dashevo/wasm-dpp build && \ cargo clean && \ sccache --show-stats @@ -56,10 +59,10 @@ RUN --mount=type=cache,target=/tmp/unplugged \ yarn workspaces focus --production @dashevo/drive && \ cp -R /platform/.yarn/unplugged /tmp/ -FROM node:16-alpine3.16 +# Remove Rust sources +RUN rm -rf packages/rs-drive packages/rs-drive-abci packages/rs-dpp packages/rs-platform-value -ARG NODE_ENV=production -ENV NODE_ENV ${NODE_ENV} +FROM node:16-alpine3.16 LABEL maintainer="Dash Developers " LABEL description="Drive Node.JS" @@ -71,9 +74,6 @@ WORKDIR /platform COPY --from=builder /platform /platform -# Remove Rust sources -RUN rm -rf packages/rs-drive packages/rs-drive-abci packages/rs-dpp packages/rs-platform-value - RUN cp /platform/packages/js-drive/.env.example /platform/packages/js-drive/.env EXPOSE 26658 diff --git a/packages/platform-test-suite/Dockerfile b/packages/platform-test-suite/Dockerfile index 320b54acfab..a4d9bd345a6 100644 --- a/packages/platform-test-suite/Dockerfile +++ b/packages/platform-test-suite/Dockerfile @@ -1,5 +1,16 @@ # syntax = docker/dockerfile:1.5 -FROM strophy/buildbase:0.0.4 as builder +FROM strophy/buildbase:0.0.6 as builder + +# TODO: Probably should be release by default +ARG CARGO_BUILD_PROFILE=debug +ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} + +ARG NODE_ENV=production +ENV NODE_ENV ${NODE_ENV} + +ARG SCCACHE_GHA_ENABLED +ARG ACTIONS_CACHE_URL +ARG ACTIONS_RUNTIME_TOKEN WORKDIR /platform @@ -33,7 +44,7 @@ COPY packages/rs-dpp packages/rs-dpp COPY packages/wasm-dpp packages/wasm-dpp # Build WASM DPP -RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ +RUN --mount=type=cache,sharing=private,target=/root/.cache/sccache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \ --mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \ @@ -49,10 +60,10 @@ RUN --mount=type=cache,target=/tmp/unplugged \ yarn workspaces focus --production @dashevo/platform-test-suite && \ cp -R /platform/.yarn/unplugged /tmp/ -FROM node:16-alpine3.16 +# Remove Rust sources +RUN rm -rf packages/rs-dpp packages/rs-platform-value -ARG NODE_ENV=production -ENV NODE_ENV ${NODE_ENV} +FROM node:16-alpine3.16 LABEL maintainer="Dash Developers " LABEL description="DAPI Node.JS" @@ -64,9 +75,6 @@ WORKDIR /platform COPY --from=builder /platform /platform -# Remove Rust sources -RUN rm -rf packages/rs-dpp packages/rs-platform-value - RUN cp /platform/packages/platform-test-suite/.env.example /platform/packages/platform-test-suite/.env EXPOSE 2500 2501 2510