question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mikhail-vlcommented, Nov 23, 2021

@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?

1reaction
crazy-maxcommented, Nov 25, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found