diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index f5b70f5..9fed2f6 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -16,7 +16,7 @@ jobs: matrix: include: - platform: linux - docker_image: gitea.staspast.click/stas/rust-node-builder:v1 + docker_image: gitea.staspast.click/stas/rust-node-builder:v2 target: x86_64-unknown-linux-gnu artifact_name: rlogg-linux-x86_64 binary_extension: "" @@ -38,39 +38,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Generate dependency hash - id: deps_hash + - name: Configure sccache run: | - # Create a hash of dependencies only (excludes package version) - # This prevents cache invalidation on version bumps - { - # Get all dependencies from Cargo.toml (skip package.version) - grep -A 9999 '^\[dependencies' Cargo.toml 2>/dev/null || true - grep -A 9999 '^\[dev-dependencies' Cargo.toml 2>/dev/null || true - grep -A 9999 '^\[build-dependencies' Cargo.toml 2>/dev/null || true - # Include Cargo.lock for exact dependency versions - cat Cargo.lock 2>/dev/null || true - } | sha256sum | cut -d' ' -f1 > /tmp/deps_hash.txt - echo "hash=$(cat /tmp/deps_hash.txt)" >> $GITHUB_OUTPUT - - - name: Cache Cargo Dependencies - uses: https://gitea.com/actions/cache@v3 - with: - # Path to cache: The 'target' directory contains all compiled libraries - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - # Key: Changes only when dependencies change, not when version changes - key: ${{ runner.os }}-cargo-${{ steps.deps_hash.outputs.hash }}-${{ matrix.target }} - # Restore Keys: Fallback to any cache for this target - restore-keys: | - ${{ runner.os }}-cargo-${{ steps.deps_hash.outputs.hash }}- - ${{ runner.os }}-cargo- - env: - # Force use of GNU tar instead of BusyBox tar - INPUT_TAR_PATH: /usr/bin/tar + # Configure sccache cache directory (persists on runner between builds) + mkdir -p /tmp/sccache + echo "SCCACHE_DIR=/tmp/sccache" >> $GITHUB_ENV + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - name: Setup cross-compilation tools if: matrix.setup_cmd != '' @@ -88,6 +61,10 @@ jobs: cargo build --release fi + # Show sccache statistics + echo "=== sccache stats ===" + sccache --show-stats + - name: Prepare artifact shell: sh run: | diff --git a/docker/build-linux-image.sh b/docker/build-linux-image.sh index 45614d2..a5c004d 100755 --- a/docker/build-linux-image.sh +++ b/docker/build-linux-image.sh @@ -1 +1 @@ -docker build -t gitea.staspast.click/stas/rust-node-builder:v1 -f linux-build.Dockerfile . && docker push gitea.staspast.click/stas/rust-node-builder:v1 \ No newline at end of file +docker build -t gitea.staspast.click/stas/rust-node-builder:v2 -f linux-build.Dockerfile . && docker push gitea.staspast.click/stas/rust-node-builder:v2 \ No newline at end of file diff --git a/docker/linux-build.Dockerfile b/docker/linux-build.Dockerfile index 49c828a..ef67fd3 100644 --- a/docker/linux-build.Dockerfile +++ b/docker/linux-build.Dockerfile @@ -6,10 +6,19 @@ RUN apt-get update && \ npm \ tar \ gzip \ + curl \ && rm -rf /var/lib/apt/lists/* && \ # Check if /bin/tar is BusyBox and replace it with GNU tar if /bin/tar --version 2>&1 | grep -q "BusyBox"; then \ cp /usr/bin/tar /bin/tar.gnu && \ rm -f /bin/tar && \ mv /bin/tar.gnu /bin/tar; \ - fi \ No newline at end of file + fi + +# Install sccache for Rust compilation caching +RUN SCCACHE_VERSION=0.7.4 && \ + SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" && \ + curl -L "$SCCACHE_URL" | tar xz && \ + chmod +x sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache && \ + mv sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache /usr/local/bin/ && \ + rm -rf sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl \ No newline at end of file