Can't restore Docker Buildx cache properly

Hi fellow developers. I’m currently stuck at an issue that keeps my build times at over 1h (which could be at around 10m if caching were working properly)

If you look for the build of one of my projects (https://github.com/D3strukt0r/docker-spigot/runs/1222194551?check_suite_focus=true), you’ll see that it recovers the build cache from the previous build under Cache Docker layers and when you check Build everything is CACHED. Nice. This is the CI file for it: https://github.com/D3strukt0r/docker-spigot/blob/7c608ce792f91d69a9d39b269ea3f01c9f62d01e/.github/workflows/ci-cd.yml

Back to the project with the 1h build time. This is the CI file: https://github.com/D3strukt0r/fhnw-artworks/blob/ec3d15aa045594827d7a3d5164e2db4f2494a006/.github/workflows/ci-cd.yml
Checking the currently latest run here (https://github.com/D3strukt0r/fhnw-artworks/runs/1222407778?check_suite_focus=true) you’ll see under Cache Docker layers that it gets the cache from the previous build just as fine. Ok great. When you look at Build API PHP (Docker) however, you’ll see the 1h build time, and nothing is CACHED. The only hint I get is this message:

time="2020-10-07T19:43:15Z" level=warning msg="local cache import at /tmp/.buildx-cache/api not found due to err: could not read /tmp/.buildx-cache/api/index.json: open /tmp/.buildx-cache/api/index.json: no such file or directory"

I also cache between test and deploy, so that I don’t need to build twice, and there it works. Under deploy everything is cached again. If you check Post Cache Docker layers it’s successful (and skipped under deploy because it’s already cached during test)

WHAT IS WRONG WITH BUILDX. Please someone help. These 1h waiting times are just annoying.

PS: I’m using these actions:

  • docker/setup-qemu-action@v1
  • docker/setup-buildx-action@v1
  • actions/cache@v2
  • docker/build-push-action@v2

@D3strukt0r,

You need to check if the file “/tmp/.buildx-cache/api/index.json” was indeed existing when you saved the cache.
I mean you need to conform if buildx indeed was installed in the directory “/tmp/.buildx-cache”.
If not, you need to find the directory where the “docker/setup-buildx-action” actually installed buildx to.

@brightran, checking the code, it doesn’t seem like docker/setup-buildx-action cares about where the cache is. But I’ll try running it again with ls -Al everywhere hahaha.

@D3strukt0r,

checking the code, it doesn’t seem like docker/setup-buildx-action cares about where the cache is.

Normally, the setup-buildx-action action should have a special path to install buildx, if the path (/tmp/.buildx-cache) you specify on the cache action is not consistent with or containing the installation path of buildx, buildx will not be saved as the part of cache.

That why I suggest you to confirm the actual installation path of buildx when using the setup-buildx-action action.