GHA cache doesn't work when building multiple images
See original GitHub issue~Is this by design and what is the recommended way of using it?~
~If it’s a bug, please confirm. Thanks!~
Looks like it’s been confirmed as a bug.
# ...
build:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: my-own-registry
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push App
uses: docker/build-push-action@v2
with:
push: true
tags: my-own-registry/my-app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
^ This takes 28s to finish after the first run
The following takes 4 minutes every single run. And the second app is actually simpler, so it shouldn’t have taken much longer.
The truth is the cache is not used at all.
# ...
build:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: my-own-registry
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push App
uses: docker/build-push-action@v2
with:
push: true
tags: my-own-registry/my-app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push App 2
uses: docker/build-push-action@v2
with:
push: true
tags: my-own-registry/my-other-app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top Results From Across the Web
GitHub Actions cache - Docker Documentation
By default, cache is scoped per Git branch. This ensures a separate cache environment for the main branch and each feature branch. If...
Read more >Build images on GitHub Actions with Docker layer caching
We'll put two jobs inside the workflow. One uses caching, and the other does not. By default, Jobs inside a GitHub Actions workflow...
Read more >Share gha Docker cache among branches? - Stack Overflow
I have a CI workflow in a github repo. This workflow builds a Docker image and pushes it to the gha cache using...
Read more >How to use Docker layer caching in GitHub Actions - Depot
With this basic workflow, we are not caching any of the Docker layers, so we have to recompute each layer for every build....
Read more >Where do you build your image in your pipeline? : r/docker
The gha image caching works quite well. ... If you only use one cache and build multiple images sequentially, then you might use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@quanton-dev, was you able to solve it? I have the same issue and it stopped working 7 days ago when the commit was made.
@crazy-max, any ideas why load build context is smaller than before?
Yes this is a known issue with buildx 0.7.0. See https://github.com/docker/buildx/issues/850#issuecomment-973880018 as a workaround in the meantime.