Skip to content

Docker image layer caching#108

Open
gloskull wants to merge 2 commits into
Utility-Protocol:mainfrom
gloskull:Docker-Image-Layer-Caching
Open

Docker image layer caching#108
gloskull wants to merge 2 commits into
Utility-Protocol:mainfrom
gloskull:Docker-Image-Layer-Caching

Conversation

@gloskull

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker Image Layer Caching Optimization for CI

1 participant