build

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProject

func BuildProject(ctx context.Context, client *Client, opts *ProjectBuildOpts) error

BuildProject builds all images in the project according to the dependency order, applying filters and pushing to the registry when dependents exist.

func PushTag

func PushTag(tagName, platformStr, buildID string) string

PushTag returns the tag to use when pushing to the registry, with platform suffix and optional build-id suffix. Format: tagName.sanitized-platform[.buildID]

func TarFilePath

func TarFilePath(distPath, name, tag, platformStr string) string

TarFilePath returns the OCI tar output path for a given image tag and platform inside the rendered dist directory. The layout is: dist/<name>/<tag>/<sanitized-platform>/image.tar

func WithBuildID

func WithBuildID(tag, buildID string) string

WithBuildID appends an optional build ID suffix to a tag. Returns the tag unchanged if buildID is empty.

Types

type BuildOpts

type BuildOpts struct {
	ImageName string
	Platform  string
	TarFile   string
	BuildArgs map[string]string
	Secrets   map[string][]byte
	Cache     cache.BuildkitCache

	// ContextDir is the build context root directory.
	ContextDir string
	// Dockerfile is the relative path to the Dockerfile within ContextDir.
	// Defaults to "Dockerfile" if empty.
	Dockerfile string

	// RegistryRef is the full image reference for direct registry push
	// (e.g. "localhost:8500/ubuntu:22.04.linux-amd64").
	RegistryRef string
	// RegistryInsecure allows pushing over HTTP.
	RegistryInsecure bool
	// DockerMediaTypes forces BuildKit's image exporter to emit Docker-scheme
	// media types (manifest, config, layers) rather than OCI. Required when
	// the target registry (e.g. Docker Hub) doesn't accept pure OCI.
	DockerMediaTypes bool

	// OCIStores maps store IDs to content stores for OCI layout named contexts.
	OCIStores map[string]content.Store
	// NamedContexts maps frontend attribute keys to OCI layout references.
	NamedContexts map[string]string

	// ProgressConfig controls how build progress is displayed.
	// When zero-valued, AutoMode with DefaultColors is used.
	ProgressConfig progress.Config
}

BuildOpts contains all parameters for a single image build.

type Client

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

Client wraps the internal BuildKit client.

func NewClient

func NewClient(ctx context.Context, endpoint string) (*Client, error)

NewClient connects to a BuildKit daemon at the given endpoint. If endpoint is empty, it falls back to BUILDKIT_HOST environment variable.

func (*Client) Build

func (c *Client) Build(ctx context.Context, opts *BuildOpts, w io.Writer) error

Build builds a container image. Progress output is written to w unless opts.ProgressConfig.Writer is set, in which case that takes precedence.

func (*Client) Close

func (c *Client) Close() error

Close releases the BuildKit connection.

func (*Client) Version

func (c *Client) Version(ctx context.Context) (string, error)

Version returns the BuildKit daemon version string.

type Filter

type Filter struct {
	ImageName string
	TagName   string
}

Filter selects a subset of images/tags to build. Empty fields match everything.

type HiveDeps

type HiveDeps struct {
	OCIStores     map[string]content.Store
	NamedContexts map[string]string
	// Dockerfile is the path to a rewritten Dockerfile where __hive__/ has been
	// replaced with a valid Docker reference prefix for named context resolution.
	Dockerfile string
	// contains filtered or unexported fields
}

HiveDeps holds the OCI layout stores and named context mappings needed to resolve inter-image dependencies via BuildKit named contexts instead of a registry.

func ResolveHiveDeps

func ResolveHiveDeps(opts HiveDepsOpts) (*HiveDeps, error)

ResolveHiveDeps scans a Dockerfile for __hive__/ references and resolves each to an OCI layout content store (local) or a docker-image:// registry reference (CI). It also creates a rewritten Dockerfile that uses a valid Docker reference prefix (hive-dep/) so BuildKit can parse it. Returns nil (not an error) when the Dockerfile has no hive dependencies.

func (*HiveDeps) Cleanup

func (d *HiveDeps) Cleanup()

Cleanup removes all temporary directories and the rewritten Dockerfile.

type HiveDepsOpts

type HiveDepsOpts struct {
	DockerfilePath string
	DistPath       string
	PlatformStr    string
	// RegistryAddress is the registry address for CI fallback resolution.
	// When set and a local tar is not found, dependencies resolve to
	// docker-image:// references pointing at the registry manifest.
	RegistryAddress string
	// BuildID is appended to registry tags when resolving via registry.
	BuildID string
}

HiveDepsOpts configures how hive dependencies are resolved.

type ProjectBuildOpts

type ProjectBuildOpts struct {
	Project     *model.ContainerHiveProject
	BuildOrder  *deps.BuildOrder
	DistPath    string
	Cache       cache.BuildkitCache
	Registry    Registry // nil when no inter-image dependencies exist
	ProgressOut io.Writer
	// ProgressConfig controls build progress display (mode, colors, no-color).
	// When zero-valued, AutoMode with DefaultColors is used.
	ProgressConfig progress.Config
	Filters        []Filter // empty = build everything
	BuildID        string   // if set, registry push/retag uses tags suffixed with .<BuildID>

	// OnBuild is called after each successful build with the image tag and tar path.
	OnBuild func(imageTag, tarFile string)
}

ProjectBuildOpts holds shared configuration for a project-wide build.

type Registry

type Registry interface {
	Address() string
	IsLocal() bool
	UseDockerMediaTypes() bool
}

Registry provides registry metadata for direct BuildKit pushes.

type ResolvedConfig

type ResolvedConfig struct {
	BuildArgs map[string]string
	Secrets   map[string][]byte
}

ResolvedConfig holds the resolved build arguments and secrets for an image build.

func ResolveTagConfig

func ResolveTagConfig(image *model.Image, tag *model.Tag) (*ResolvedConfig, error)

ResolveTagConfig resolves build args and secrets for a specific image tag.

func ResolveVariantConfig

func ResolveVariantConfig(image *model.Image, variant *model.ImageVariant, tag *model.Tag) (*ResolvedConfig, error)

ResolveVariantConfig resolves build args and secrets for a specific image tag variant.

Jump to

Keyboard shortcuts

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