Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

ADR 0009: CI Build Optimization Strategy

Status

Accepted

Context

Rust compilation is notoriously slow, particularly when building from scratch in CI environments. As the kroki-rs project grows and introduces more features (e.g., native-browser), the CI cycle time has increased, impacting developer productivity and feedback loops.

We need a strategy that:

  1. Reduces Local CI-verify Time: Fast local verification via ./dflow ci-verify.

  2. Optimizes GitHub Actions: Minimal compute usage and faster PR checks.

  3. Ensures Portability: Works across Docker, Podman, and GHA.

  4. Supports Multi-Arch: Builds for linux/amd64 and linux/arm64.

Trade-off Analysis

StrategySpeed (Cache Hit)PortabilityProsCons
cargo-chefFast (Layer based)High (Standard Docker)Best for GHA; robust for workspaces.Invalidates on any dependency change.
BuildKit CacheVery Fast (Mount)Medium (GHA requires setup)Persists even if layers mismatch.Can be tricky to share across different CI hosts.
sccacheModerate (Network)Very High (S3/Cloud)Global cache across all PRs/Archs.Linking is still a bottleneck; network overhead.
Persistent VolumeInstant (Local)Low (Host-bound)No upload/download; real-time reuse.Not available in ephemeral CI workers.

Decision

We will implement a Dual Caching Strategy:

  1. cargo-chef as the primary layering mechanism in the Dockerfile. This ensures that dependencies are cached in standard Docker layers, which is highly effective and portable for GitHub Actions.

  2. BuildKit Cache Mounts (--mount=type=cache) for the Cargo registry and git folders. This provides a secondary speedup for both local and CI builds by persisting downloaded crates and git data even when the Cargo.lock changes.

  3. Local Persistent Volume for the target directory in ./dflow ci-verify. This allows for near-instant re-runs locally by bypassing the slow linking phase.

Consequences

Implementation (2026-02-23): Content-addressable identity and GHA parity

Benchmarks (Verified 2026-02-23)