Skip to content

fix: replace --mount=type=cache with dependency layer caching#34

Merged
mikkeldamsgaard merged 1 commit intomainfrom
fix/docker-layer-caching
Mar 11, 2026
Merged

fix: replace --mount=type=cache with dependency layer caching#34
mikkeldamsgaard merged 1 commit intomainfrom
fix/docker-layer-caching

Conversation

@mikkeldamsgaard
Copy link
Contributor

Summary

  • Replaced --mount=type=cache with the "empty main" dependency layer caching trick in both Dockerfile and jyq.Dockerfile
  • --mount=type=cache does not persist across GitHub Actions runners, causing full Rust recompilation on every release build
  • The dependency layer caching pattern (copy Cargo.toml/lock → build with dummy main.rs → remove initium artifacts → copy real source → rebuild) leverages Docker's built-in layer cache and works reliably with GitHub Actions' type=gha cache

Test plan

  • Verify Docker build succeeds locally: docker build -t initium .
  • Verify jyq variant builds: docker build -f jyq.Dockerfile -t initium-jyq .
  • Confirm CI passes
  • Verify next release build is faster (dependency layer cached)

🤖 Generated with Claude Code

…erfiles

--mount=type=cache does not persist across GitHub Actions runners,
causing full recompilation on every release build. Reintroduce the
"empty main" trick for reliable Docker layer caching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 11, 2026 23:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the project’s container build process to use Docker layer caching (via the “empty main.rs” dependency-build pattern) instead of BuildKit --mount=type=cache, improving cache reuse across GitHub Actions runners. It also documents the change in the changelog.

Changes:

  • Replaced --mount=type=cache usage with a dependency-layer caching approach in both Docker build variants.
  • Adjusted final-stage binary copy paths to pull directly from target/release/initium.
  • Added a changelog entry under [Unreleased] describing the Docker caching fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Dockerfile Switches to dependency-layer caching to speed up repeat builds in CI and updates final binary copy path.
jyq.Dockerfile Applies the same caching strategy for the jq/yq Alpine variant and updates final binary copy path.
CHANGELOG.md Documents the Docker build caching change under the Unreleased “Fixed” section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mikkeldamsgaard mikkeldamsgaard merged commit c28f834 into main Mar 11, 2026
10 checks passed
@mikkeldamsgaard mikkeldamsgaard deleted the fix/docker-layer-caching branch March 11, 2026 23:20
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.

2 participants