kbld icon indicating copy to clipboard operation
kbld copied to clipboard

How to efficiently cache docker layer in CI with kbld?

Open StarpTech opened this issue 3 years ago • 6 comments

Hi, I know kbld is builder neutral, but what's the best practice to cache docker layers in the CI? As far I know, the default docker CLI is very limited when it comes to caching. docker buildx has much better support, but kbld doesn't support it yet https://github.com/vmware-tanzu/carvel-kbld/issues/43

StarpTech avatar Dec 24 '21 02:12 StarpTech

Hi, I know kbld is builder neutral, but what's the best practice to cache docker layers in the CI?

There's no special pattern for caching docker layers in CI; kbld delegates building images and is not involved in that layer, directly.

As noted in #43 (apt reference, 👍🏻 ), there's some design work left to start the integration with docker buildx. That issue is a great place to further the larger conversation. At this time, this work is not currently on the maintainer's roadmap. That said, we would be delighted and do our best to support any community efforts to do so.

pivotaljohn avatar Jan 04 '22 22:01 pivotaljohn

Hi @pivotaljohn thanks. It would be great to hear how caching is solved in general in your experience. Especially, when kbld limits you to use just docker build.

StarpTech avatar Jan 05 '22 09:01 StarpTech

docker buildx has much better support, but kbld doesn't support it yet #43

@StarpTech im not versed in buildx. how does it help in this scenario? does it cache layers in a registry, and downloads it from there? how do you see kbld integration to play out here (what is the command kbld should be calling to use buildx)?

cppforlife avatar Jan 06 '22 22:01 cppforlife

does it cache layers in a registry, and downloads it from there? how do you see kbld integration to play out here (what is the command kbld should be calling to use build)?

Basically, yes. https://github.com/moby/buildkit#cache Rebuilding all images is unusable. Especially in the CI where the storage ephemeral.

StarpTech avatar Jan 07 '22 12:01 StarpTech

@StarpTech would you be able to share what kind of command you would-want/already to be running? (we probably need a bit more hand holding from users like you on how to integrate with buildkit)

cppforlife avatar Jan 18 '22 16:01 cppforlife

added docker buildx build support in https://github.com/vmware-tanzu/carvel-kbld/releases/tag/v0.34.0. you should also be able to use various caching configuration if you enable docker.build.buildkit configuration option or set env variable.

cppforlife avatar Jun 09 '22 01:06 cppforlife