-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildx library as a higher-level buildkit client #1483
Comments
Buildx first and foremost, is a CLI tool. There is a Go client library in BuildKit and I don't think it makes sense for us to maintain two different sets of Go libraries that do the same thing. The amount of Go devs who want to write their own code to interact with BuildKit instead of calling Docker tools directly isn't so big that a different library needs to exist for every taste or level of abstraction(or other people can do it, for example Dagger who have written their own proxy variant). If the BuildKit client lib can be improved, we should do the work there. This shouldn't compromise on the capabilities that the current library has, just to make it simpler. Buildx does separate Adding some very specific extra abstractions like the gRPC struct doesn't probably improve the general reusability but may increase the maintenance cost for future buildx dev. The most important goal of this repo is to allow us to iterate quickly on opinionated user-facing build features. -- If your problem is that some of the existing drivers are not powerful enough, we should really extend the capabilities of that driver, not try to reimplement buildx functionality in another tool. Every time |
No, actually very much the opposite, I just find that the driver abstraction is not useful for deploying builders, the remote driver is already a good example, the interface is very foced there. Stateful parts are also unhelpful in my use-case, I need to be able to create multiple clients from a single long-running process, and I would rather not worry about state that these clients may write to disk and accidentily collide with one another.
My suggestion to expose
I cannot possibly agree with this. The current shape of
I'd use it, by why is invoking it takes so many lines of code in buildx?
I don't mind the location, just seemed like buildx had the code already that should be easy enough to tease apart from some assumptions. |
Because buildx implements many more features that are out of scope for buildkit, like drivers (and driver-specific exceptions in build), multi-targets, multi-node split & join, frontend fallbacks, old CLI compatibility etc. Buildx code is opinionated while BuildKit is general-purpose and reusable.
In driver interface, the Driver provides the whole What I was referring with my earlier comment was that there are a lot of possible low-level options that buildx does not expose because it doesn't use them. Adding one specific one would only solve one exception. For the |
I do understand this, and it's clear from buildx code that it was written to be a CLI. However, BuildKit client relies on very weak interfaces. It uses maps that appear to be documented only by examples, and most of the examples I've seen are so long, that I wouldn't dare to adopt. If the API was complex, but didn't rely on maps, I would be less hesitant to create my own abstactions. The arbitrary nature of maps is very daunting to build any abstractions upon. On the contrary, buildx has |
Problem statement
When I looked at using buildkit API from a Go program, I ended up comparing what buildctl does to what buildx does and very quickly realised that buildx is a lot more advanced. I find it hard to tell what pieces I may need to borrow to create a lightweight and robust client that is able to do nearly as much as buildx.
However, currently it's not very trivial to just call buidx functions, one needs to figure out how to setup the drivers the right way, and may need to also use
github.com/docker/cli/cli/command
andgithub.com/docker/buildx/store
, which do seem like very desirable dependecies for just any applications that might need embedding a buildkit client. Namely,command.Cli
appeare very Docker-spefic, andstore
package is very specific to buildx's state management needs as CLI.In my case I have a set of addreesses of remote buildkit deamons and TLS credentials (as structs like
struct { ca, cert, key []byte }
), and I'd like to either setup generic gRPC clients for each of these and create a buildkit client from that, or otherwise at very least setup buildkit client without owning the gRPC client setup also.For this case I find that buildx remote driver abstraction is not very useful, and it also took me a lot of time to figure out how to set it up. However, I do find that
build.Options
struct and most of the logic inbuild.BuildWithResultHandler
is quite useful, especiallytoSolveOpt
appears to have what most comprehensive clients need to do.I certainly don't want to copy some code from buildx and then maintain it. Neither I want to shell-out (for multiple reasons).
Proposal
Povide a simpler API that does most things that build package currently offers, but without CLI-centric assumptions and design aroind an equivalent of remote driver (i.e. initialised with a gRPC client or a URL). This API doesn't have to offer strong stability guarantees, it could be evolving in the way that buildx project currently does, but it's best if it stays disentanlged from the CLI use-case.
I am not sure what
BuildResult
should look like, but ideally it shouldn't be a nested map like it is right now, it needs to be more structured.The text was updated successfully, but these errors were encountered: