Help us shape the future of Go! Take the 2026 Go Developer Survey

build

package
v0.4.0-beta.12 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package build turns a source tree without a compose file into a container image. Each way of building is a Builder; a Registry tries them in order and the first that recognizes the tree builds it. Adding or replacing a builder is a registration, not a change to the deploy flow.

Index

Constants

View Source
const RailpackFrontend = "ghcr.io/railwayapp/railpack-frontend"

RailpackFrontend is the BuildKit frontend image that executes a Railpack plan.

Variables

View Source
var ErrRailpackMissing = errors.New("railpack is not installed on this server; install it with the FlatRun installer or from https://railpack.com to build repositories without a Dockerfile")

Functions

func ImageTag

func ImageTag(deployment, revision string) string

ImageTag names the image built for a deployment at a revision.

Types

type Builder

type Builder interface {
	Name() Kind
	// Detect reports whether this builder can build the tree in dir.
	Detect(dir string) bool
	Build(ctx context.Context, req Request, sink func(string)) error
}

type Dockerfile

type Dockerfile struct {
	Run Runner
}

Dockerfile builds a tree with the Dockerfile at its root.

func (Dockerfile) Build

func (d Dockerfile) Build(ctx context.Context, req Request, sink func(string)) error

func (Dockerfile) Detect

func (Dockerfile) Detect(dir string) bool

func (Dockerfile) Name

func (Dockerfile) Name() Kind

type Kind

type Kind string

Kind names how a source runs: KindCompose for a tree that brings its own compose file, otherwise the Name of the builder that builds it.

const KindCompose Kind = "compose"
const KindDockerfile Kind = "dockerfile"
const KindRailpack Kind = "railpack"

type Railpack

type Railpack struct {
	Run      Runner
	LookPath func(string) (string, error)
}

Railpack builds any tree by detecting its language and framework, so it accepts every directory and belongs last in a registry.

func (Railpack) Build

func (r Railpack) Build(ctx context.Context, req Request, sink func(string)) error

func (Railpack) Detect

func (Railpack) Detect(string) bool

func (Railpack) Name

func (Railpack) Name() Kind

type Registry

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

Registry holds builders in priority order.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry builds with the repository's own Dockerfile when it has one and falls back to Railpack's zero-config detection.

func NewRegistry

func NewRegistry(builders ...Builder) *Registry

func (*Registry) Build

func (r *Registry) Build(ctx context.Context, kind Kind, req Request, sink func(string)) error

func (*Registry) Detect

func (r *Registry) Detect(dir string) Kind

Detect picks how a source tree runs: its compose file, else the first builder that recognizes it. It returns "" when nothing can build it.

func (*Registry) Get

func (r *Registry) Get(kind Kind) (Builder, bool)

type Request

type Request struct {
	Dir     string
	Scratch string
	Tag     string
}

Request is one build: the source tree, a scratch directory outside it for builder-generated files, and the image tag to produce.

type Runner

type Runner func(ctx context.Context, name string, args []string, sink func(string)) error

Runner executes one command, streaming its combined output lines to sink.

Jump to

Keyboard shortcuts

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