-
Notifications
You must be signed in to change notification settings - Fork 134
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
WIP - Use buildkit for building images #264
WIP - Use buildkit for building images #264
Conversation
Description: - Build images using buildkit - Adds git submodules for buildkit gRPC codegen - Doesn't work yet, but we get a HTTP 101 when upgrading via /session endpoint on the docker API
This looks really fabulous.. I'm going to make some room this weekend to play around with it. Are you using a reference implementation from somewhere ? |
No, this is just from going through what docker CLI does. I think it might almost work, I'm seeing a JSON data error, perhaps a different response format is being used.
If you have any questions @fussybeaver feel free to reach out |
|
If I try with a valid build config I also get let docker = Docker::connect_with_unix_defaults().unwrap();
let mut build_image_args = HashMap::new();
build_image_args.insert("dummy", "value");
let mut build_image_labels = HashMap::new();
build_image_labels.insert("maintainer", "somemaintainer");
let build_image_options = BuildImageOptions {
t: "bollard-build-buildkit-example",
dockerfile: "Dockerfile",
version: BuilderVersion::BuilderBuildKit,
..Default::default()
};
let filename = &args().nth(1).expect("needs first argument");
let archive = File::open(filename).await.expect("could not open file");
let stream = FramedRead::new(archive, BytesCodec::new());
let body = Body::wrap_stream(stream);
let mut image_build_stream = docker.build_image(build_image_options, None, Some(body));
while let Some(msg) = image_build_stream.next().await {
println!("Message: {:?}", msg);
} |
Would love to help on this in any way possible! Trying to integrate Bollard into Nixpacks (Railway's Opensource Build Engine) instead of calling the local client so that we can do remote builds Our caching system requires --mount, which requires buildkit. I might try and play with this tomorrow to see if I can get something going myself |
There's definitely some moving parts that need to be tamed. The relevant moby code that spins up buildkit is here. The Unfortunately, the protobuf in the buildkit repository doesn't seem to compile cleanly with tonic/prost at the moment, so it could be useful to figure out how that's supposed to work and how to integrate it into the Bollard codebase. Other observations I want to take a look at:
|
Edit: managed to get a simple
Caveats:
|
@fussybeaver That is amazing! Is there anything you need a hand with? I hope no one feels I just drop this unfinished 😅 For the tonic lib fetching dependencies, pretty sure that is out of scope for the project. Two things I can think of:
Second might be easier to track with versioning? |
@cmac4603 very grateful about the initial work, clearly it's not straightforward and needs some iterations. Including git submodules might work, but these have
So out-of-the-box tonic/prost won't handle it, though I guess there's possibly some options/flags that might work. Possible also to kick this can down the road and maybe deal with it later. |
Totally spitballing here, but there's a Session RPC call, and the SolveRequest takes a Session string Wouldn't be surprised if the GRPC sessions for buildkit were materially different from the http sessions, and thus you'd need to pre-negotiate the session using the GRPC API and use that |
So, an update here, I have managed to get buildkit working for public repositories in #276 , and will merge this into master soon. The solution was actually to invert the grpc relationship (bollard is the grpc server, buildkit acts as a client), hook up tonic's existing type system that accepts an Some remaining work, if anyone is interested (not sure I'll have the time this year), is implementing the grpc |
@fussybeaver I wouldn't mind taking a look after the first part is merged |
WIP - Doesn't work
Description:
Run the buildkit test