1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! BuildKit Rust Client
//!
//! A Rust client library for interacting with BuildKit to build container images.
//!
//! # Features
//!
//! - Build from local Dockerfile or GitHub repository
//! - Support for private GitHub repositories with authentication
//! - Push images to registries with authentication
//! - Multi-platform builds
//! - Build arguments, target stages, and advanced options
//! - Real-time progress monitoring
//! - Cache import/export
//!
//! # Examples
//!
//! ## Build from local Dockerfile
//!
//! ```no_run
//! use buildkit_client::{BuildKitClient, BuildConfig, RegistryAuth};
//! use buildkit_client::progress::ConsoleProgressHandler;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let mut client = BuildKitClient::connect("http://localhost:1234").await?;
//!
//! let config = BuildConfig::local("./my-app")
//! .tag("localhost:5000/my-app:latest")
//! .build_arg("VERSION", "1.0.0");
//!
//! let progress = Box::new(ConsoleProgressHandler::new(true));
//! let result = client.build(config, Some(progress)).await?;
//!
//! println!("Image digest: {:?}", result.digest);
//! Ok(())
//! }
//! ```
//!
//! ## Build from GitHub repository
//!
//! ```no_run
//! use buildkit_client::{BuildKitClient, BuildConfig};
//! use buildkit_client::progress::ConsoleProgressHandler;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let mut client = BuildKitClient::connect("http://localhost:1234").await?;
//!
//! let config = BuildConfig::github("https://github.com/user/repo.git")
//! .git_ref("main")
//! .github_token("ghp_your_token_here")
//! .tag("localhost:5000/my-app:latest");
//!
//! let progress = Box::new(ConsoleProgressHandler::new(true));
//! let result = client.build(config, Some(progress)).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Multi-platform build with registry authentication
//!
//! ```no_run
//! use buildkit_client::{BuildKitClient, BuildConfig, Platform, RegistryAuth};
//! use buildkit_client::progress::ConsoleProgressHandler;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let mut client = BuildKitClient::connect("http://localhost:1234").await?;
//!
//! let config = BuildConfig::local(".")
//! .platform(Platform::linux_amd64())
//! .platform(Platform::linux_arm64())
//! .tag("docker.io/myuser/myapp:latest")
//! .registry_auth(RegistryAuth {
//! host: "docker.io".to_string(),
//! username: "myuser".to_string(),
//! password: "mytoken".to_string(),
//! });
//!
//! let progress = Box::new(ConsoleProgressHandler::new(true));
//! let result = client.build(config, Some(progress)).await?;
//!
//! println!("Multi-platform image built: {:?}", result.digest);
//! Ok(())
//! }
//! ```
// Re-export main types
pub use ;
pub use BuildKitClient;
pub use BuildResult;
pub use ;