Skip to content

πŸ¦€ x 🐳 A Rust client library and CLI for interacting with moby/buildkit via gRPC, implementing the complete BuildKit Session Protocol

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

arcbox-labs/buildkit-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BuildKit Rust Client

Crates.io Documentation License Rust Version

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


Features

  • 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

Prerequisites

  • Rust 1.70+
  • Docker or BuildKit daemon
  • Git (for fetching proto files)

Installation

As a Library

Add to your Cargo.toml:

[dependencies]
buildkit-client = "0.1" # or bkit if you like
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"

As a CLI Tool

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.

Quick Start

See Usage Guide for detailed CLI and library usage examples.

Project Structure

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

BuildKit gRPC API

This project directly uses BuildKit's gRPC API:

  • Control.Solve - Execute build operations
  • Control.Status - Stream build status updates
  • Control.Info - Get BuildKit information
  • Control.Session - Bidirectional session stream

All protobuf definitions are fetched from the moby/buildkit repository.

Documentation

Troubleshooting

BuildKit Connection Failed

# Check if BuildKit is running
docker-compose ps

# View BuildKit logs
docker-compose logs buildkitd

# Restart services
docker-compose restart

Registry Push Failed

Ensure the registry allows insecure connections (for localhost):

# docker-compose.yml
services:
  buildkitd:
    environment:
      - BUILDKIT_REGISTRY_INSECURE=true

Proto Compilation Errors

If 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 build

Proto files are now automatically managed by build.rs. See Development Guide for details.

Development

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 linter

Architecture

This 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.

License

This project is dual-licensed under MIT OR Apache-2.0.

Acknowledgments

  • moby/buildkit - BuildKit project
  • tonic - Rust gRPC library
  • prost - Protocol Buffers implementation
  • h2 - HTTP/2 implementation

Contributing

Contributions are welcome! Please feel free to submit Issues and Pull Requests.

Before submitting a PR:

  1. Run cargo fmt and cargo clippy
  2. Ensure all tests pass: cargo test
  3. Add tests for new features
  4. Update documentation as needed

Related Links


⬆ back to top

Made with ❀️ by AprilNEA

About

πŸ¦€ x 🐳 A Rust client library and CLI for interacting with moby/buildkit via gRPC, implementing the complete BuildKit Session Protocol

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •