Builder not using cache
See original GitHub issueBehaviour
Hi, I can’t seem to get the build-push-action to use the restored cache when building. I’ve tried following the steps in the market place instructions and recommendation here: https://github.com/docker/build-push-action/issues/132#issuecomment-699502544, but to no avail.
The logs indicate that the cache is restored, but when the build runs it seems to build everything from scratch.
Steps to reproduce
I have this in a test repo here: https://github.com/ltamrazov/testingactions
Expected behaviour
Cache is used to rebuild images on rerunning a workflow and on any new workflow run.
Actual behaviour
Images are rebuild from scratch.
Configuration
- Repository URL (if public): https://github.com/ltamrazov/testingactions
- Build URL (if public): https://github.com/ltamrazov/testingactions/runs/1203552549
name: ci
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Builder
uses: docker/setup-buildx-action@v1
id: buildx
- name: Cache main image layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Checkout Code
uses: actions/checkout@v2
- name: Determine Image Tag
id: generate_tag
run: |
_tag=latest
if [ "${{ github.event_name }}" == "pull_request" ]
then
_tag=pr-${{ github.event.number }}
fi
_full=test/dev:${_tag}
echo ::set-output name=tag::${_full}
- name: Build code
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
push: false
target: test
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
tags: ${{ steps.generate_tag.outputs.tag }}
- name: Build DB
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
file: Dockerfile.postgres
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
tags: db-${{ steps.generate_tag.outputs.tag }}
- name: Run Tests
run: |
API_IMAGE_TAG=${{ steps.generate_tag.outputs.tag }} DB_IMAGE_TAG=db-${{ steps.generate_tag.outputs.tag }} docker-compose -f docker-compose.yml --env-file .env.ci run test-api
Logs
Thank you!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Docker build is not using cache - Stack Overflow
I am modifying the Dockerfile, adding commands at the end of the file. So the previous layers should be cached and valid. I've...
Read more >Builder not using cache for unmodified build stages?
It seems to me that the reason is the builder doesn't reuse cache for certain stages in the multistage build. An example of...
Read more >Docker build not using cache - GitLab Forum
I am trying to speed up my Docker build by using the --cache-from option. ... Notice that for example step [builder 4/6] is...
Read more >Caching challenges and strategies - Amazon AWS
Cached data necessarily grows inconsistent with the source over time, so caching can only be successful if both the service and its clients...
Read more >UX Builder not loading WP-total cache | WordPress.org
Hi, i use flatsome for my website but for some reason i'm stuck in a loading loop for the UX Builder. I tried...
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
Hi @ltamrazov
That’s because your cache is mixed with 2 images. You have to create another cache:
Tested: https://github.com/crazy-max/testingactions/runs/1204121486?check_suite_focus=true
aaah, ya that did the trick. After pruning it started to rebuild from scratch, so it was never using the specified cache. Thank you for the quick response and your time!