Skip to content

ci: switch Docker GHA cache to mode=min to reduce cache bloat#1152

Merged
BenjaminMichaelis merged 3 commits into
mainfrom
benjaminmichaelis/debug-docker-cache
May 23, 2026
Merged

ci: switch Docker GHA cache to mode=min to reduce cache bloat#1152
BenjaminMichaelis merged 3 commits into
mainfrom
benjaminmichaelis/debug-docker-cache

Conversation

@BenjaminMichaelis
Copy link
Copy Markdown
Member

Problem

The main branch Docker build workflow was using cache-to: type=gha,mode=max, which saves all intermediate build layers (50+ stages). Combined with recent workflow changes, this caused the repo GHA cache to balloon to ~10 GB, hitting GitHub's per-repo limit and triggering eviction of the essentialcsharpweb-main scope layers. Result: subsequent builds saw 0% cache hit despite warm cache.

Solution

Switch to cache-to: type=gha,mode=min on the main branch deploy workflow.

  • mode=min saves only the final exported layers (base image + published app binaries)
  • cache-from still reads everything available, so builds benefit from layer reuse on unchanged stages
  • Expected cache footprint reduction: ~60% (6.7 GB → ~2.5 GB)
  • No impact on cache hit rates for stable/slow-changing layers

Changes

  • .github/workflows/Build-Test-And-Deploy.yml: line 95, change mode=max to mode=min

This is a safe, read-path-agnostic change — pulling behavior is unaffected, only what gets written changes.

Switching from mode=max to mode=min on the main branch workflow cache-to
saves only the final exported layers (as opposed to all intermediate layers).
This significantly reduces GHA cache storage pressure while maintaining layer
reuse benefits, since cache-from still pulls everything available regardless
of save mode.

Expected impact: reduces Docker layer cache footprint by ~60% without
affecting cache hit rates on stable layers.
Copilot AI review requested due to automatic review settings May 22, 2026 16:47
Copy link
Copy Markdown
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

Adjusts the main-branch build/test/deploy GitHub Actions workflow to reduce GitHub Actions cache growth from Docker Buildx layer exports, helping avoid cache eviction and improving CI reliability for the EssentialCSharp.Web deployment pipeline.

Changes:

  • Switch Docker Buildx cache-to export on main workflow from mode=max to mode=min for the essentialcsharpweb-main GHA cache scope.

outputs: type=docker,dest=${{ github.workspace }}/essentialcsharpwebimage.tar
cache-from: type=gha,scope=essentialcsharpweb-main
cache-to: type=gha,mode=max,scope=essentialcsharpweb-main
cache-to: type=gha,mode=min,scope=essentialcsharpweb-main
Same fix as the deploy workflow - reduces cache footprint without
affecting pull behavior.
Keep main workflow on mode=max and leave mode=min only in PR workflow as requested in review.
Copilot AI review requested due to automatic review settings May 22, 2026 23:58
Copy link
Copy Markdown
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

type=gha,scope=essentialcsharpweb-main
type=gha,scope=essentialcsharpweb-pr
cache-to: type=gha,mode=max,scope=essentialcsharpweb-pr
cache-to: type=gha,mode=min,scope=essentialcsharpweb-pr
@BenjaminMichaelis BenjaminMichaelis merged commit b30e901 into main May 23, 2026
9 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the benjaminmichaelis/debug-docker-cache branch May 23, 2026 00:09
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