buildkit

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package buildkit wires an in-process BuildKit solver into ephemerd.

The server type holds a *control.Controller configured with:

  • a containerd worker pointed at ephemerd's embedded containerd
  • the Dockerfile frontend plus the gateway.v0 frontend
  • bbolt-backed cache and history stores under <dataDir>/buildkit

Callers interact with the server through the Build method, which accepts a high-level BuildOpts describing a Docker-style build request and returns a progress stream. The Docker-API translation layer lives in pkg/dind.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DataDir is where BuildKit stores its cache, history, and content.
	// Typically <ephemerd data dir>/buildkit.
	DataDir string

	// ContainerdAddress is the address of ephemerd's embedded containerd
	// gRPC endpoint. On Linux this is a unix socket path; on Windows it's
	// a named pipe (e.g. "npipe:////./pipe/ephemerd-containerd").
	ContainerdAddress string

	// ContainerdNamespace is the containerd namespace buildkit should use
	// for image and content storage. Defaults to "buildkit" if empty.
	ContainerdNamespace string

	// Snapshotter selects the containerd snapshotter. Defaults to "overlayfs"
	// on Linux and "windows" on Windows.
	Snapshotter string

	// Network manages container networking. Required on Windows so build
	// containers get an HCN NAT endpoint (otherwise RUN steps that hit the
	// internet exit immediately). Ignored on platforms where buildkit's
	// default network providers already work.
	Network *networking.Manager

	// Log receives structured logging from the buildkit server.
	Log *slog.Logger
}

Config configures an embedded BuildKit Server.

type Server

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

Server hosts an in-process BuildKit Controller and the supporting objects (session manager, worker controller, caches) it needs. Callers interact with the controller through a buildkit client.Client obtained from the Client() method; the client dials an in-process bufconn listener that the Controller serves on, so no network socket is exposed.

func NewServer

func NewServer(ctx context.Context, cfg Config) (*Server, error)

NewServer constructs and initializes an embedded BuildKit server. The returned Server is ready to accept Build calls but does not expose a network listener; it is used in-process only.

func (*Server) Build

func (s *Server) Build(ctx context.Context, opt client.SolveOpt, statusCh chan *client.SolveStatus) (*client.SolveResponse, error)

Build performs a Docker-style build using the embedded BuildKit solver. Progress events are written to statusCh as they arrive; statusCh is closed by the underlying solve when the build terminates. Build itself blocks until the solve completes and returns the solve response.

The caller constructs SolveOpt from Docker build options (this is the translation layer pkg/dind owns). def is nil when using a frontend like dockerfile.v0 — the frontend loads the definition from the build context supplied via SolveOpt.LocalMounts.

func (*Server) Client

func (s *Server) Client(ctx context.Context) (*client.Client, error)

Client returns a buildkit client.Client connected to the in-process Controller via bufconn. The returned Client is not safe for concurrent use across different callers — construct one per request/goroutine and Close it when done.

func (*Server) Close

func (s *Server) Close() error

Close signals the Controller to shut down gracefully, stops the in-process gRPC server, and releases worker resources. Safe to call multiple times.

func (*Server) SessionManager

func (s *Server) SessionManager() *session.Manager

SessionManager exposes the session manager so callers (pkg/dind) can hijack incoming POST /session HTTP streams into session gRPC.

Jump to

Keyboard shortcuts

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