buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

Proposal: Specify standard export and caching APIs

Open cpuguy83 opened this issue 2 years ago • 5 comments

Right now buildkit can export a build in a number of ways, to moby, containerd, etc. I propose to have buildkit define a standard API for handling exports and caching. This could allow a client to specify an export to some external system that buildkit knows nothing about other than that it conforms to buildkit's API. To support new systems for image storage or caching backends no new code needs to be added to buildkit itself and admins/users can implement adapters for their own infrastructure.

This could also allow moby to implement the API such that even a containerized buildkit instance (such as buildx creates) can export images to moby without having to go through the tar/load API. Blobs can be stored directly in moby (I mean, probably in containerd but directed there by moby).

cpuguy83 avatar May 08 '23 16:05 cpuguy83

How do you think this API would look like? Is it a blob-only API? Is it like a frontend component that is also loadable today?

tonistiigi avatar May 08 '23 18:05 tonistiigi

How do you think this API would look like? Is it a blob-only API?

I'm not sure without digging into the details of what buildkit needs here. I just wanted to see if people were amenable to this idea.

Is it like a frontend component that is also loadable today?

That is an interesting idea. Something on the cli like --output=type=docker-image://<ref>?

cpuguy83 avatar May 15 '23 15:05 cpuguy83

Yeah I brought up something similar here in a discussion about making exports more modular: https://github.com/moby/buildkit/issues/3037#issuecomment-1235034356

I like this general idea a lot. Between all the code in cache for supporting stargz, nydus, etc. and all the different remotecache implementations, creating something more modular/pluggable could be extremely beneficial to the codebase besides just being more flexible for users.

sipsma avatar Jun 13 '23 17:06 sipsma

Thinking about this more, ideally any current exporter should be able to be implemented behind the new "standard" interface. So support for tags would be needed but not required. Probably some other things as well. So not just a blob interface.

cpuguy83 avatar Nov 20 '23 20:11 cpuguy83

This API becomes very useful with the recent changes to the docker-hub pricing.

Since Friday I have been jumping here and there around, trying to find out how to push the images to S3 reliably from our CI hosts. And a possible point-of-deny as a host with a registry:2 container looks redundant there.

Felixoid avatar Sep 16 '24 14:09 Felixoid