Docker image layer caching#108
Open
gloskull wants to merge 2 commits into
Open
Conversation
…ing-for-ci Optimize CI Docker layer caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Reduce CI build time by reusing dependency layers across the repository's Rust, contracts, WASM, and JS services.
Provide an explicit cache-warming job that validates buildability and populates BuildKit/GHA caches without publishing images.
Keep Docker build contexts small and safer by excluding local deps, build outputs, and VCS metadata.
Description
Add Dockerfile.ci with BuildKit-enabled, multi-stage targets and cache mounts for Cargo registries, Cargo git checkouts, Cargo target directories, and npm caches, covering rust-root-test, contracts-test, wasm-build, meter-simulator-test, and usage-dashboard-build targets.
Add a GitHub Actions docker-layer-cache matrix job that runs docker/build-push-action@v6 with cache-from/cache-to set to type=gha and a per-target scope to persist and restore layer metadata.
Add .dockerignore to exclude .git, .github, **/target, **/node_modules, .next, coverage and other local/build artifacts from Docker contexts.
Add docs/CI_DOCKER_LAYER_CACHING.md runbook documenting architecture, CI behavior, monitoring, rollout (blue/green + canary) and security notes, and add small placeholders in the Dockerfile to allow cargo fetch for workspace crates.
Use an ARG RUST_VERSION=stable and standardize node image usage for JS targets to ensure reproducible builds.
Testing
Ran cargo fmt --all -- --check and it succeeded.
Ran cargo clippy --all-targets --all-features -- -D warnings and it succeeded.
Ran cargo test --locked and it succeeded.
Verified workflow YAML parsing with a Ruby check and git diff --check; both checks succeeded, and local Docker builds were skipped because the Docker CLI is not available in this environment.
Closes #82