Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache is discarded in partial successful builds #756

Closed
peredwardsson opened this issue Jan 11, 2023 · 3 comments
Closed

Cache is discarded in partial successful builds #756

peredwardsson opened this issue Jan 11, 2023 · 3 comments

Comments

@peredwardsson
Copy link

Troubleshooting

Before submitting a bug report please read the Troubleshooting doc.

Behaviour

If a docker image is not successfully built as part of this step, and cache is being handled as in #252 (comment), then the cache is discarded. This means that all partial success is thrown away, leading to tons of extra work for me. 😇

Steps to reproduce this issue

  1. Make a big Dockerfile.
  2. Set it up as in Pretty big cache #252 (comment)
  3. Have it fail midway through.

Expected behaviour

The layers which worked should be saved for the future in the cache.

Actual behaviour

All layers associated with the Dockerfile is thrown away, even the good ones.

Configuration

See #252 (comment)

@MichaelVoelkel
Copy link

YES! Please fix this.

Some kind of workaround could be to let manually use restore/save of the cache action. But not sure how to combine this with cha cache-from / cache-to gha

@DiegoRBaquero
Copy link

Would this be possible? This was generated by ChatGPT:

- name: Build and Cache Step 1
        run: docker build -t myimage:step1 --target=step1 --cache-from=type=gha .

      - name: Push Docker Image Step 1
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: myimage:step1
          cache-to: type=gha,mode=max,scope=l1

      - name: Build and Cache Step 2
        run: docker build -t myimage:step2 --target=step2 --cache-from=type=gha .

      - name: Push Docker Image Step 2
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: myimage:step2
          cache-to: type=gha,mode=max

@crazy-max
Copy link
Member

crazy-max commented Mar 8, 2024

Looks like a duplicate of #252, let's continue the discussion there. Also you should consider switching to gha cache exporter: https://docs.docker.com/build/ci/github-actions/cache/#github-cache

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

No branches or pull requests

4 participants