A full-featured Rust client library and CLI for interacting with moby/buildkit to build container images via gRPC.
Features β’ Installation β’ Quick Start β’ Usage β’ Documentation β’ Contributing
- Complete gRPC Implementation - Direct integration with BuildKit's gRPC API
- Multiple Build Sources - Support for local Dockerfiles and GitHub repositories
- Authentication Support - GitHub private repositories and Docker Registry authentication
- Advanced Build Options - Build args, target stages, multi-platform builds
- Real-time Progress - Live build progress and log streaming
- Cache Management - Support for cache import/export
- Registry Push - Automatic push of built images to registries
- Session Protocol - Full implementation of BuildKit's bidirectional session protocol
- HTTP/2 Tunneling - HTTP/2-over-gRPC for file synchronization
- Rust 1.70+
- Docker or BuildKit daemon
- Git (for fetching proto files)
Add to your Cargo.toml:
[dependencies]
buildkit-client = "0.1" # or bkit if you like
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"git clone https://github.com/corespeed-io/buildkit-client.git
cd buildkit-client
cargo install --path .Proto files are automatically managed during build - no manual setup required.
See Usage Guide for detailed CLI and library usage examples.
buildkit-client/
βββ src/
β βββ main.rs # CLI tool entry point
β βββ lib.rs # Library entry point
β βββ client.rs # BuildKit gRPC client
β βββ builder.rs # Build configuration
β βββ solve.rs # Build execution logic
β βββ progress.rs # Progress handling
β βββ session/ # Session protocol implementation
β β βββ mod.rs # Session lifecycle & metadata
β β βββ grpc_tunnel.rs # HTTP/2-over-gRPC tunnel
β β βββ filesync.rs # File synchronization
β β βββ auth.rs # Registry authentication
β βββ proto.rs # Protobuf generated code
βββ proto/ # BuildKit protobuf definitions
βββ examples/ # Sample Dockerfiles
βββ tests/ # Comprehensive test suite
βββ docker-compose.yml # Test environment setup
βββ README.md
This project directly uses BuildKit's gRPC API:
Control.Solve- Execute build operationsControl.Status- Stream build status updatesControl.Info- Get BuildKit informationControl.Session- Bidirectional session stream
All protobuf definitions are fetched from the moby/buildkit repository.
- Quick Start Guide - Get up and running quickly
- Usage Guide - CLI and library usage examples with configuration options
- Architecture Guide - Complete architecture and protocol documentation
- Development Guide - Development workflows, testing, and proto management
- Testing Guide - Complete testing documentation (unit, integration, GitHub builds)
- Implementation Notes - Detailed implementation notes for contributors
# Check if BuildKit is running
docker-compose ps
# View BuildKit logs
docker-compose logs buildkitd
# Restart services
docker-compose restartEnsure the registry allows insecure connections (for localhost):
# docker-compose.yml
services:
buildkitd:
environment:
- BUILDKIT_REGISTRY_INSECURE=trueIf you encounter protobuf compilation errors:
# Force rebuild (will redownload proto files)
cargo clean
PROTO_REBUILD=true cargo build
# Or use clone mode if download fails
PROTO_FETCH_MODE=clone cargo buildProto files are now automatically managed by build.rs. See Development Guide for details.
For detailed development workflows, testing strategies, and proto management, see Development Guide.
Quick commands:
make build # Build project
make test # Run tests
make up # Start docker-compose services
cargo fmt # Format code
cargo clippy # Run linterThis project implements a complete BuildKit gRPC client with:
- Bidirectional gRPC streaming for real-time communication
- HTTP/2-over-gRPC tunneling for BuildKit callbacks
- DiffCopy protocol for efficient file synchronization
- Session management with proper metadata handling
- Registry authentication support
For detailed architecture documentation, see Architecture Guide.
This project is dual-licensed under MIT OR Apache-2.0.
- moby/buildkit - BuildKit project
- tonic - Rust gRPC library
- prost - Protocol Buffers implementation
- h2 - HTTP/2 implementation
Contributions are welcome! Please feel free to submit Issues and Pull Requests.
Before submitting a PR:
- Run
cargo fmtandcargo clippy - Ensure all tests pass:
cargo test - Add tests for new features
- Update documentation as needed
Made with β€οΈ by AprilNEA