Buildx caching in CI not working without load: true #3339
Unanswered
mikepurvis
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a bit of an odd one but I started my project with a single large Dockerfile of about twenty stages + a heavily matrixed bake config. The early "deps" stage of the build was installing 6GB+ worth of dependencies, so I set it up to export a generated "preinstall" Dockerfile that acts as a kind of lockfile for some cache layers. Basically the generated Dockerfile looks like this:
And then the main Dockerfile is:
I don't want to actually push the preinstall image anywhere, so I hoped I could just wire together the targets at the bake file level, basically just doing
contexts = { preinstall = "target:preinstall" }
. Should be a dream for caching, right, with everything super explicit like that?All this works great on my workstation, but the issue I'm having on CI is that buildx seems to be unwilling to recognize that those preinstall layers are available in cache. I really don't want to push these to their own layer on the registry and would rather just use
cache-to
andcache-from
.What seems to work is if, in my Actions workflow, I do this:
This causes the preinstall layers to get loaded into the buildx instance and then the main bake is able to recognize and use them. Things I tried that did not work:
load: true
. Without this, the apt-preinstall step goes by so fast that I suspect buildx realises it doesn't actually have to do any work and doesn't even download the layers. But I'd like a way to force it to make the download without also wasting time making tarballs to transfer into the runner's docker instance.cache-from
block, it will insist on rebuilding the preinstall layers.What did also work was putting a tiny cache-busting shim layer at the bottom of the preinstall dockerfile. Building this in the preinstall Actions step forces it to actually perform the download and then the cache layers are present in buildx and everything else goes as expected. This feels like a really unfortunate hack, though.
Obviously the ideal would be if the build backend was able to directly pull cached layers for targets wired together at the bakefile level, but failing that, it would also be great if there was an option in
docker/bake-action
that was was likepush
andload
but instead of actually copying anything, it would just force the builder to fully realise the targets into its own layer storage.Does that make sense? Is there some other path I'm not seeing here? Would it be helpful to try to prepare a MWE that demonstrates the issue or is this a manifestation of something that's already well known and understood?
Beta Was this translation helpful? Give feedback.
All reactions