buildx

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

pkg/buildx

The buildx package abstracts container image building and pushing across Docker, Podman, and Buildah. It is the single place in Orkestra that shells out to a container builder — no other package runs docker build directly.

What lives here

File Role
buildx.go Builder interface, BuildImage / PushImage public API, builder selection
builders.go DockerBuilder, PodmanBuilder, BuildahBuilder — one struct per supported tool
compose_init.go InitConfig, AppEntry — persist ork doctor init settings to .orkestra/bundle/.init.ork for ork doctor deploy to read

Builder auto-selection

BuildImage and PushImage call selectBuilder(), which walks AllBuilders in order and returns the first one whose binary is found in PATH:

AllBuilders = [DockerBuilder, PodmanBuilder, BuildahBuilder]

The user never selects a builder — the first available tool wins. This makes the same ork doctor deploy command work in Docker Desktop, Podman Machine, and CI environments that only have Buildah.

Public API

// Build an image from a directory.
err := buildx.BuildImage(dir, image, buildx.ComposeBuild{}, w)

// Push an already-built image.
err := buildx.PushImage(image, w)

ComposeBuild controls how the image is built:

type ComposeBuild struct {
    UseCompose  bool   // true → docker compose build
    ComposeFile string // path to docker-compose.yaml (only when UseCompose)
    Dockerfile  string // path to Dockerfile; empty → "Dockerfile" in dir
}

Developer documentation

I want to… Go to
Understand builder selection and the Builder interface docs/01-builders.md
Understand InitConfig and the .init.ork file format docs/02-init-config.md

Documentation

Index

Constants

This section is empty.

Variables

AllBuilders is the ordered list of supported builders. First available one wins.

Functions

func BuildImage

func BuildImage(dir, image string, compose ComposeBuild, w io.Writer) error

BuildImage builds an image using the first available builder.

func CleanupInitConfig

func CleanupInitConfig(dir string) error

CleanupInitConfig removes .orkestra/bundle/.init.ork after a successful deployment.

func GetInitConfigPath

func GetInitConfigPath(dir string) string

GetInitConfigPath returns the absolute path to the .init.ork file located within the Orkestra bundle directory.

The file is stored at: <dir>/.orkestra/bundle/.init.ork This directory is ignored by git (via .gitignore rule for .orkestra/bundle/), ensuring the init configuration remains local to the environment and is not accidentally committed to version control.

The caller is responsible for creating the parent directories and the file itself. Use WriteInitConfig to write content, LoadInitConfig to load content and CleanupInitConfig to remove the file after a successful deployment.

func PushImage

func PushImage(image string, w io.Writer) error

PushImage pushes an image using the first available builder.

func WriteInitConfig

func WriteInitConfig(dir string, useCompose bool, composeFile string) error

WriteInitConfig persists a single-app or compose config to .orkestra/bundle/.init.ork.

func WriteInitConfigFull

func WriteInitConfigFull(dir string, cfg InitConfig) error

WriteInitConfigFull writes the full InitConfig to .orkestra/bundle/.init.ork.

Types

type AppEntry

type AppEntry struct {
	Name       string // app name — used for image tag, CR name, and katalog dir
	Dir        string // absolute path to the app's build context directory
	Dockerfile string // path to Dockerfile (absolute or relative); empty = "Dockerfile" in Dir
}

AppEntry represents one application in a multi-app project.

type BuildahBuilder

type BuildahBuilder struct{}

func (BuildahBuilder) Available

func (BuildahBuilder) Available() bool

func (BuildahBuilder) Build

func (BuildahBuilder) Build(dir, image string, compose ComposeBuild, w io.Writer) error

func (BuildahBuilder) Name

func (BuildahBuilder) Name() string

func (BuildahBuilder) Push

func (BuildahBuilder) Push(image string, w io.Writer) error

type Builder

type Builder interface {
	Name() string
	Build(dir, image string, compose ComposeBuild, w io.Writer) error
	Push(image string, w io.Writer) error
	Available() bool
}

Builder is the interface implemented by all container builders.

type ComposeBuild

type ComposeBuild struct {
	UseCompose  bool   // true → use compose build
	ComposeFile string // path to docker-compose.yaml (only when UseCompose)
	Dockerfile  string // path to Dockerfile; empty → "Dockerfile" in the build dir
}

ComposeBuild describes how to build a container image.

type DockerBuilder

type DockerBuilder struct{}

func (DockerBuilder) Available

func (DockerBuilder) Available() bool

func (DockerBuilder) Build

func (DockerBuilder) Build(dir, image string, compose ComposeBuild, w io.Writer) error

func (DockerBuilder) Name

func (DockerBuilder) Name() string

func (DockerBuilder) Push

func (DockerBuilder) Push(image string, w io.Writer) error

type InitConfig

type InitConfig struct {
	UseCompose  bool       // true → compose-based build
	ComposeFile string     // path to docker-compose.yaml (only when UseCompose)
	Apps        []AppEntry // one entry per buildable app; empty = legacy single-app
}

InitConfig is the full configuration persisted in .orkestra/bundle/.init.ork. It bridges `ork doctor init` settings through to `ork doctor deploy`.

func LoadInitConfig

func LoadInitConfig(dir string) (InitConfig, error)

LoadInitConfig reads .orkestra/bundle/.init.ork and returns the full InitConfig. Returns an empty InitConfig (no error) when the file does not exist.

type PodmanBuilder

type PodmanBuilder struct{}

func (PodmanBuilder) Available

func (PodmanBuilder) Available() bool

func (PodmanBuilder) Build

func (PodmanBuilder) Build(dir, image string, compose ComposeBuild, w io.Writer) error

func (PodmanBuilder) Name

func (PodmanBuilder) Name() string

func (PodmanBuilder) Push

func (PodmanBuilder) Push(image string, w io.Writer) error

Jump to

Keyboard shortcuts

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