buildkit

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions

type BuildOptions struct {
	Dockerfile string            // Reserved for future use - currently unused
	Tag        string            // Image tag (e.g., "moat/run:abc123")
	ContextDir string            // Build context directory
	NoCache    bool              // Disable build cache
	Platform   string            // Target platform (e.g., "linux/amd64")
	BuildArgs  map[string]string // Build arguments
	Output     io.Writer         // Progress output (default: os.Stdout)
}

BuildOptions configures a BuildKit build.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps BuildKit client operations. Supports two connection modes:

  • Standalone: connects to an external BuildKit daemon via BUILDKIT_HOST (e.g., dind sidecar)
  • Embedded: connects to Docker Desktop's built-in BuildKit via DialHijack on /grpc and /session

func NewClient

func NewClient() (*Client, error)

NewClient creates a BuildKit client. Connects to the address specified in BUILDKIT_HOST env var (e.g., "tcp://buildkit:1234")

func NewEmbeddedClient added in v0.2.0

func NewEmbeddedClient(
	contextDialer func(context.Context, string) (net.Conn, error),
	sessionDialer func(context.Context, string, map[string][]string) (net.Conn, error),
) *Client

NewEmbeddedClient creates a BuildKit client that connects to Docker's embedded BuildKit via DialHijack. This is the connection method used by `docker buildx` when talking to Docker Desktop's built-in BuildKit instance.

The contextDialer connects to /grpc for BuildKit RPCs. The sessionDialer connects to /session for file sync, auth callbacks, etc.

func (*Client) Build

func (c *Client) Build(ctx context.Context, opts BuildOptions) error

Build executes a build using BuildKit.

The build process:

  1. Connects to BuildKit (standalone via BUILDKIT_HOST, or embedded via DialHijack)
  2. Prepares build context from ContextDir using LocalMounts (BuildKit manages session internally)
  3. Executes build with dockerfile.v0 frontend
  4. Exports the result: - Standalone: Docker image tar piped to `docker load` - Embedded: "moby" exporter stores image directly in Docker's image store

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks if BuildKit is reachable.

func (*Client) WaitForReady

func (c *Client) WaitForReady(ctx context.Context) error

WaitForReady waits for BuildKit to become ready with exponential backoff. BuildKit daemon takes ~5-10s to initialize after sidecar starts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL