buildkit

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package buildkit provides a component for managing a persistent BuildKit daemon using containerd. BuildKit is used for building container images with layer caching across builds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	Log       *slog.Logger
	CC        *containerd.Client
	Namespace string
	DataPath  string
	// contains filtered or unexported fields
}

Component manages a persistent BuildKit daemon as a containerd container, or connects to an external BuildKit daemon via Unix socket.

func NewComponent

func NewComponent(log *slog.Logger, cc *containerd.Client, namespace, dataPath string) *Component

NewComponent creates a new BuildKit component that manages an embedded daemon.

func NewExternalComponent

func NewExternalComponent(log *slog.Logger, socketPath string) *Component

NewExternalComponent creates a BuildKit component that connects to an external daemon. No container lifecycle management is performed - it only provides client access.

func (*Component) Client

func (c *Component) Client(ctx context.Context) (*buildkitclient.Client, error)

Client returns a new BuildKit client connected to the daemon.

func (*Component) IsRunning

func (c *Component) IsRunning() bool

IsRunning returns whether the BuildKit daemon is running.

func (*Component) SetRegistryIP

func (c *Component) SetRegistryIP(ip string) error

SetRegistryIP updates the hosts file with the registry IP address for cluster.local. This can be called after Start() once the registry IP is known.

func (*Component) SocketPath

func (c *Component) SocketPath() string

SocketPath returns the path to the BuildKit Unix socket.

func (*Component) Start

func (c *Component) Start(ctx context.Context, config Config) error

Start starts the BuildKit daemon container. For external components, this verifies the socket is accessible.

func (*Component) Stop

func (c *Component) Stop(ctx context.Context) error

Stop stops the BuildKit daemon container. For external components, this is a no-op.

type Config

type Config struct {
	// SocketDir is the directory where the Unix socket will be created (e.g., /run/miren/buildkit)
	SocketDir string

	// RegistryIP is the IP address for cluster.local registry (optional, can be set later via SetRegistryIP)
	RegistryIP string

	// GCKeepStorage is the maximum bytes of cache to keep (default: 10GB)
	GCKeepStorage int64

	// GCKeepDuration is how long to keep cache entries in seconds (default: 7 days)
	GCKeepDuration int64

	// RegistryHost is the hostname for the cluster-local registry (e.g., cluster.local:5000)
	RegistryHost string

	// DNSNameservers are the nameserver addresses build steps resolve against.
	// See generateConfig for why we override buildkit's default here.
	DNSNameservers []string

	// Traces is where buildkitd exports its spans.
	Traces TracesExport
}

Config contains configuration for the BuildKit component.

type TracesExport added in v0.17.0

type TracesExport struct {
	// Endpoint replaces OTEL_EXPORTER_OTLP_ENDPOINT, for a destination that
	// came from server config rather than the env.
	Endpoint string

	// Relayed means Endpoint is the server's loopback relay, which holds the
	// credentials. buildkitd lives far longer than a workload identity token
	// and has no way to refresh one, so it gets no collector credentials at
	// all, only RelaySecret, and speaks the only protocol the relay does.
	Relayed bool

	// RelaySecret is what the relay requires of its callers. It is stable
	// across server restarts, so it doesn't make buildkitd's container churn.
	RelaySecret string

	// Disabled keeps buildkitd from exporting traces. It is what traces get
	// when they need a token and the relay isn't there to supply one: better
	// no build spans than a static credential the operator asked to retire.
	Disabled bool
}

TracesExport says where buildkitd sends its spans, as the server resolved it. The zero value forwards the server's OTel env untouched.

Jump to

Keyboard shortcuts

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