Skip to content

Commit

Permalink
Merge pull request #450 from levinwinter/moby-buildkit-output
Browse files Browse the repository at this point in the history
Custom Build Outputs `--output`
  • Loading branch information
fussybeaver authored Aug 19, 2024
2 parents 1be9ccf + 1ddbf48 commit 9574c61
Show file tree
Hide file tree
Showing 13 changed files with 1,210 additions and 25 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ members = [
[features]
default = []
# Enable Buildkit-enabled docker image building
buildkit = ["chrono", "num", "rand", "tokio/fs", "tokio-stream", "tokio-util/io", "tonic", "tower-service", "ssl", "bollard-stubs/buildkit", "bollard-buildkit-proto"]
buildkit = ["chrono", "num", "rand", "tokio/fs", "tokio-stream", "tokio-util/io", "tonic", "tower-service", "ssl", "bollard-stubs/buildkit", "bollard-buildkit-proto", "dep:async-stream", "dep:bitflags"]
# Enable tests specifically for the http connector
test_http = []
# Enable tests specifically for rustls
Expand Down Expand Up @@ -77,6 +77,8 @@ tokio-stream = { version = "0.1", features = ["net"], optional = true }
tower-service = { version = "0.3", optional = true }
url = "2.5"
webpki-roots = { version = "0.26", optional = true }
async-stream = { version = "0.3.5", optional = true }
bitflags = { version = "2.6.0", optional = true }

[dev-dependencies]
flate2 = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion codegen/proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ tonic = { version = "0.12" }
prost = { version = "0.13" }
prost-types = "0.13"
tonic-build = { version = "0.12", optional = true }
ureq = { version = "2.9.7", optional = true, default-features = false }
ureq = { version = "2.9.7", features = ["tls"], optional = true, default-features = false }

23 changes: 23 additions & 0 deletions codegen/proto/resources/moby/filesync/v1/filesync.packet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";

package moby.filesync.v1;

option go_package = "filesync";

import "fsutil/types/wire.proto";

// FileSync exposes local files from the client to the server.
service FileSync{
rpc DiffCopy(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
rpc TarStream(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
}

// FileSend allows sending files from the server back to the client.
service FileSend{
rpc DiffCopy(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
}

// BytesMessage contains a chunk of byte data
message BytesMessage {
bytes data = 1;
}
13 changes: 12 additions & 1 deletion codegen/proto/src/bin/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
destination: "moby/filesync/v1/filesync.proto",
source: "https://raw.githubusercontent.com/moby/buildkit/master/session/filesync/filesync.proto",
replacements: vec![
("github.com/tonistiigi/fsutil/types/wire.proto", "fsutil/types/wire.proto")
("github.com/tonistiigi/fsutil/types/wire.proto", "fsutil/types/wire.proto")
]
},
Resource {
destination: "moby/filesync/v1/filesync.packet.proto",
source: "https://raw.githubusercontent.com/moby/buildkit/master/session/filesync/filesync.proto",
replacements: vec![
("github.com/tonistiigi/fsutil/types/wire.proto", "fsutil/types/wire.proto"),
(
"service FileSend{\n rpc DiffCopy(stream BytesMessage) returns (stream BytesMessage);\n}",
"service FileSend{\n rpc DiffCopy(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);\n}"
)
]
},
Resource {
Expand Down
13 changes: 13 additions & 0 deletions codegen/proto/src/bin/gen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
use std::fs;

use tonic_build;

fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.out_dir("src/generated")
.compile_well_known_types(true)
.compile(
&["resources/moby/filesync/v1/filesync.packet.proto"],
&["resources"],
)?;
fs::copy(
"src/generated/moby.filesync.v1.rs",
"src/generated/moby.filesync.packet.rs"
).expect("could not move file");
tonic_build::configure()
.out_dir("src/generated")
.compile_well_known_types(true)
Expand Down
Loading

0 comments on commit 9574c61

Please sign in to comment.