Skip to content

Enable docker layer caching for dry-run and nightly container builds#36738

Merged
lunny merged 9 commits intogo-gitea:mainfrom
silverwind:docker-gha-cache
Mar 1, 2026
Merged

Enable docker layer caching for dry-run and nightly container builds#36738
lunny merged 9 commits intogo-gitea:mainfrom
silverwind:docker-gha-cache

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Feb 24, 2026

Enable Docker BuildKit layer caching for the dry-run and nightly container build workflows using GHCR registry cache.

  • Dry-run (pull-docker-dryrun.yml): adds cache-from, read-only, PRs can't write cache
  • Nightly (release-nightly.yml): adds cache-from and cache-to to both read and write cach

Add cache-from/cache-to with GitHub Actions cache backend to all
docker/build-push-action steps to speed up container image builds by
reusing cached layers across runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 24, 2026
@silverwind silverwind added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Feb 24, 2026
@silverwind silverwind changed the title Enable BuildKit GHA cache for container builds Enable GHA cache for container builds Feb 24, 2026
@silverwind silverwind changed the title Enable GHA cache for container builds Enable layer caching for container builds Feb 24, 2026
@silverwind silverwind requested a review from Copilot February 24, 2026 12:34
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

Enables GitHub Actions cache-backed layer caching for Docker Buildx builds across release and PR container workflows to speed up repeated builds.

Changes:

  • Added cache-from: type=gha and cache-to: type=gha,mode=max to regular and rootless container build steps in tag-based release workflows.
  • Added the same GitHub Actions cache configuration to nightly and PR dry-run multi-arch container builds.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
.github/workflows/release-tag-version.yml Adds GitHub Actions cache import/export to release container builds.
.github/workflows/release-tag-rc.yml Adds GitHub Actions cache import/export to RC container builds.
.github/workflows/release-nightly.yml Adds GitHub Actions cache import/export to nightly container builds.
.github/workflows/pull-docker-dryrun.yml Adds GitHub Actions cache import/export to PR dry-run container builds.

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

silverwind and others added 2 commits February 24, 2026 13:40
The `cache-to: type=gha` directive requires `actions: write` permission
to export the BuildKit cache to the GitHub Actions cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fork PRs cannot write to the GHA cache even with actions: write
permission. Only keep cache-from since the nightly workflow will
keep the cache populated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 4 out of 4 changed files in this pull request and generated no new comments.


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

Only keep layer caching for dry-run and nightly builds where it
provides consistent benefit. Release builds happen too infrequently
for the cache to be useful and caching could lead to stale Alpine
packages in release images.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind silverwind changed the title Enable layer caching for container builds Enable GHA layer caching for dry-run and nightly container builds Feb 25, 2026
@silverwind silverwind changed the title Enable GHA layer caching for dry-run and nightly container builds Enable GHA layer caching for dry-run and nightly container builds Feb 25, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 25, 2026
@TheFox0x7
Copy link
Copy Markdown
Contributor

oh btw, why cache to GHA and not registry? Any specific reason?

@silverwind
Copy link
Copy Markdown
Member Author

Which registry would it use? I want this to be reliable so if you suggest a private registry as cache, I don't think it would be as reliable as GHA.

@TheFox0x7
Copy link
Copy Markdown
Contributor

TheFox0x7 commented Feb 26, 2026

ghcr? I don't have experience with GHA cache and buildkit so it's mostly a question why that over a registry - not a request to change to one.

@silverwind
Copy link
Copy Markdown
Member Author

No particular reason. I basically asked Claude to suggest a caching and the only thing it suggested was GHA cache.

@silverwind
Copy link
Copy Markdown
Member Author

I checked the registry topic and it's probably the cleaner approach given that GHA cache is shared with other artifacts like dependency caches. So registry is likely a better option given that there is practically no size limit there.

silverwind and others added 2 commits February 26, 2026 23:40
Use registry-type cache stored at ghcr.io/go-gitea/gitea:buildcache
instead of GitHub Actions cache. Registry cache has no size limit
unlike the 10GB GHA cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

Using registry. No auth necessary as the write action already has auth and the read action needs not auth for a public repo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind silverwind changed the title Enable GHA layer caching for dry-run and nightly container builds Enable docker layer caching for dry-run and nightly container builds Mar 1, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 1, 2026
@lunny lunny added topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Mar 1, 2026
@lunny lunny enabled auto-merge (squash) March 1, 2026 20:23
@lunny lunny merged commit 08254cf into go-gitea:main Mar 1, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Mar 1, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 1, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 2, 2026
* giteaofficial/main: (21 commits)
  Enable docker layer caching for `dry-run` and `nightly` container builds (go-gitea#36738)
  Add admin badge to navbar avatar (go-gitea#36790)
  WorkflowDispatch api optionally return runid (go-gitea#36706)
  upgrade minimatch (go-gitea#36760)
  Add `never` option to `PUBLIC_URL_DETECTION` configuration (go-gitea#36785)
  Refactor avatar package, support default avatar fallback (go-gitea#36788)
  Mark unused&immature activitypub as "not implemented" (go-gitea#36789)
  Add “Copy Source” to markup comment menu (go-gitea#36726)
  Update Nix flake (go-gitea#36787)
  Implements OIDC RP-Initiated Logout (go-gitea#36724)
  Fix README symlink resolution in subdirectories like .github (go-gitea#36775)
  [skip ci] Updated translations via Crowdin
  Correct spelling (go-gitea#36783)
  refactor: replace legacy tw-flex utility classes with flex-text-block/inline (go-gitea#36778)
  Fix `no-content` message not rendering after comment edit (go-gitea#36733)
  Fix typos and grammar in English locale (go-gitea#36751)
  Move Fomantic dropdown CSS to custom module (go-gitea#36530)
  Use "Enable Gravatar" but not "Disable" (go-gitea#36771)
  feat: add branch_count to repository API (go-gitea#35351) (go-gitea#36743)
  Deprecate RenderWithErr (go-gitea#36769)
  ...
@silverwind silverwind deleted the docker-gha-cache branch March 2, 2026 04:27
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Mar 8, 2026

It seems the container build still have uncached go/js dependencies and these regularily fail because of gitea.com/codeberg.org downtime:

https://github.com/go-gitea/gitea/actions/runs/22816127536/job/66181314879

I guess we can extract the dependencies into a separate docker layer so they are always cached until go.sum / pnpm-lock.yml changes, eliminating these downloads on every run.

@silverwind
Copy link
Copy Markdown
Member Author

It seems the container build still have uncached go/js dependencies and these regularily fail because of gitea.com/codeberg.org downtime:

https://github.com/go-gitea/gitea/actions/runs/22816127536/job/66181314879

I guess we can extract the dependencies into a separate docker layer so they are always cached until go.sum / pnpm-lock.yml changes, eliminating these downloads on every run.

#36864 will fix that.

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

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/internal skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants