Closed Wenzel closed 4 months ago
Having the same issue. I'm trying all of the variously proposed options to get my github action cache to persist across multiple runners, cannot figure it out. So I tried running the build 2 times in the same runner, both times getting this issue where
WARNING: local cache import at /tmp/.buildx-cache not found due to err: could not read /tmp/.buildx-cache/index.json: open /tmp/.buildx-cache/index.json: no such file or directory
Run: https://github.com/mozilla/addons-server/actions/runs/8019019347/job/21906086963?pr=21893
You need to set the actions/cache
step in our workflow otherwise cache is not retained across runs. See our docs: https://docs.docker.com/build/ci/github-actions/cache/#local-cache
Tried in this repo through https://github.com/docker/build-push-action/pull/1066 and looks good to me:
Also you should consider using the gha
cache backend which is more efficient: https://docs.docker.com/build/ci/github-actions/cache/#github-cache
Thanks for testing and pointing to the docs @crazy-max.
I tried your setup, and the cache works for me (replacing /tmp/.buildx-cache
by /tmp/.docker-cache
)
$ du -h /tmp/.docker-cache/
1.6G /tmp/.docker-cache/blobs/sha256
1.6G /tmp/.docker-cache/blobs
4.0K /tmp/.docker-cache/ingest
1.6G /tmp/.docker-cache/
But as soon as I replace this path with ~/.cache/docker-ci
, the caching doesn't work anymore.
That folder remains empty.
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: ~/.cache/docker-ci
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
I tried to remove this folder, and let the workflow create it, but it didn't work either.
So I'm puzzled as to what really happens, and i'm forced to use a path starting with /tmp
here.
Also you should consider using the gha cache backend which is more efficient: https://docs.docker.com/build/ci/github-actions/cache/#github-cache
That solution would be suitable if the cache content wasn't sensitive or private, which is the case here.
path: ~/.cache/docker-ci
Don't think actions/cache@v4
expands ~
. You should use an absolute dir.
Contributing guidelines
I've found a bug, and:
Description
I'm running Docker on a Self Hosted Github Actions Runner, and I've configured a local cache path at
~/.cache/docker-ci
, as well as specifying it inbuild-push-action
fields.However, the cache remains empty after each build
Expected behaviour
The cache should be populated and used by Docker to speedup the future builds.
Actual behaviour
The cache remains empty:
Repository URL
No response
Workflow run URL
No response
YAML workflow
Workflow logs
BuildKit logs
No response
Additional info
Related closed issue that I found:
I can't share the repository as it's a private project.