buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

Supporting multiple cache exports

Open mortargrind opened this issue 3 years ago • 2 comments

Hello. I've noticed that specifying multiple --cache-to values in a docker buildx build command is not supported directly. Found this comment: https://github.com/moby/buildkit/blob/master/control/control.go#L283 and this convo https://github.com/moby/buildkit/pull/615#discussion_r244895119. Is this still fairly easy to have or is there no plan supporting it in the near future?

My use-case is: I am trying to utilize new BuildKit caching capabilities in my CI pipeline to speed things up and if I am able to export 2 caches for a single Dockerfile stage (like one tagged/named as latest and other one as GITHUB_SHA or branch_name) then I think I can maximize the cache hit ratio for a lot of different scenarios. Basically a CI job for a fresh PR would first use the latest cache but on subsequent re-runs of the same job would be able to use GITHUB_SHA/branch_name one since using multiple cache-from is allowed already.

mortargrind avatar Apr 20 '22 22:04 mortargrind

Is this still fairly easy to have or is there no plan supporting it in the near future?

There shouldn't be big technical issues with adding this. But still somebody needs to implement it.

(like one tagged/named as latest and other one as GITHUB_SHA) then I think I can maximize the cache hit ratio for a lot of different scenarios

Looks like in your case you don't even need the multiple exports but ability to set multiple ref names for registry export.

tonistiigi avatar Apr 20 '22 23:04 tonistiigi

Hi, I have the same usecase. (export-cache on buildctl to multiple refs) What would need to be done to implement this?

remidebette avatar Jun 24 '22 13:06 remidebette