stackbuild

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectAugmentations added in v0.8.0

func DetectAugmentations(dir, primaryStack string) (augs []Augmentation, skipInstall bool, events []DetectionEvent)

DetectAugmentations returns the set of augmentations needed for the app located at dir, given the primary stack that was already selected.

It returns nil (no augmentations) when the primary stack is "node" or "bun", since those stacks already ship npm or bun in their base image. The returned events describe what was detected so they can be surfaced alongside primary stack detection events in the build output.

npm is triggered by the presence of package.json (not just package-lock.json), to preserve compatibility with apps — most notably Rails — that ship a package.json for asset pipelines without committing a lockfile.

skipInstall is true when the app already ships a node_modules directory — in that case the JS tooling (npm/bun) is still installed so onBuild commands can use it, but the package install step is skipped because the user's vendored node_modules will be brought in by copyApp.

Types

type Augmentation added in v0.8.0

type Augmentation string

Augmentation represents a secondary toolchain layered onto the primary stack's base image. Augmentations are detected from lockfiles in the app directory (e.g. package-lock.json -> npm) and let apps written in one language pull in auxiliary build tooling — most commonly JS package managers used to build frontend assets for a Rails/Django/Go web app.

const (
	AugNpm  Augmentation = "npm"
	AugYarn Augmentation = "yarn"
	AugBun  Augmentation = "bun"
)

type BuildOptions

type BuildOptions struct {
	Log interface{ Info(string, ...any) }

	// Name is the name of the application being built
	Name string

	// Version specifies the language/runtime version to use
	// If empty, defaults to latest stable version
	Version string

	// CacheNS specifies the namespace for persistent cache mounts
	CacheNS string

	// The alpine image to use for the base image.
	AlpineImage string

	OnBuild []string

	// EnvVars are user-configured environment variables to inject into build steps
	// (onBuild commands, asset precompilation). These are set on intermediate LLB
	// states only and do not persist to the final image config.
	EnvVars map[string]string
}

BuildOptions contains configuration for stack builds

type BunStack

type BunStack struct {
	MetaStack
	// contains filtered or unexported fields
}

BunStack implements Stack for Bun

func (*BunStack) BaseDistro added in v0.8.0

func (s *BunStack) BaseDistro() string

func (*BunStack) Detect

func (s *BunStack) Detect() bool

func (*BunStack) GenerateLLB

func (s *BunStack) GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

func (*BunStack) Init added in v0.2.0

func (s *BunStack) Init(opts BuildOptions)

func (*BunStack) Name

func (s *BunStack) Name() string

func (*BunStack) RequiredEnvVars added in v0.8.0

func (s *BunStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns the detected environment variable requirements

func (*BunStack) WebCommand added in v0.2.0

func (s *BunStack) WebCommand() string

type DetectionEvent added in v0.2.0

type DetectionEvent struct {
	Kind    string // e.g., "file", "package", "framework", "config"
	Name    string // e.g., "Gemfile", "rails", "puma"
	Message string // Human-readable description
}

DetectionEvent represents something detected during stack analysis

type EnvVarRequirement added in v0.8.0

type EnvVarRequirement struct {
	Name         string // e.g., "DATABASE_URL"
	Source       string // "gem", "code", "config", "rails_core"
	Confidence   string // "required", "recommended", "optional"
	Reason       string // e.g., "pg gem detected in Gemfile"
	CanGenerate  bool   // true if Miren can auto-generate a value (e.g., SECRET_KEY_BASE)
	ReadFromFile string // if set, read value from this file path (relative to app dir)
	DefaultValue string // if set, this is the default value to use (non-secret)
}

EnvVarRequirement represents a detected environment variable requirement

type GoStack

type GoStack struct {
	MetaStack
	// contains filtered or unexported fields
}

GoStack implements Stack for Go

func (*GoStack) BaseDistro added in v0.8.0

func (s *GoStack) BaseDistro() string

func (*GoStack) Detect

func (s *GoStack) Detect() bool

func (*GoStack) GenerateLLB

func (s *GoStack) GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

func (*GoStack) Init added in v0.2.0

func (s *GoStack) Init(opts BuildOptions)

func (*GoStack) Name

func (s *GoStack) Name() string

func (*GoStack) RequiredEnvVars added in v0.8.0

func (s *GoStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns the detected environment variable requirements

func (*GoStack) WebCommand added in v0.2.0

func (s *GoStack) WebCommand() string

type MetaStack

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

MetaStack provides shared functionality for all stack implementations

func (*MetaStack) AddEnv

func (s *MetaStack) AddEnv(key, value string)

func (*MetaStack) Augmentations added in v0.8.0

func (s *MetaStack) Augmentations() []Augmentation

Augmentations returns the secondary tooling layers (npm, bun, ...) attached to this stack by DetectStack.

func (*MetaStack) Entrypoint

func (s *MetaStack) Entrypoint() string

func (*MetaStack) Event added in v0.2.0

func (s *MetaStack) Event(kind, name, message string)

Event adds a detection event

func (*MetaStack) Events added in v0.2.0

func (s *MetaStack) Events() []DetectionEvent

Events returns all detection events

func (*MetaStack) Image

func (s *MetaStack) Image() ocispecs.Image

func (*MetaStack) Init added in v0.2.0

func (s *MetaStack) Init(opts BuildOptions)

func (*MetaStack) RequiredEnvVars added in v0.8.0

func (s *MetaStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns nil by default; stacks can override to provide detected env vars

func (*MetaStack) SetCmd

func (s *MetaStack) SetCmd(cmd []string)

func (*MetaStack) SetCwd

func (s *MetaStack) SetCwd(cwd string)

func (*MetaStack) SetEntrypoint

func (s *MetaStack) SetEntrypoint(ep []string)

func (*MetaStack) SkipJSInstall added in v0.8.0

func (s *MetaStack) SkipJSInstall() bool

SkipJSInstall reports whether the app already ships a node_modules directory, in which case the JS package install (npm install / bun install) should be skipped — the tool itself is still installed so onBuild commands can use it.

type NodeStack

type NodeStack struct {
	MetaStack
	// contains filtered or unexported fields
}

NodeStack implements Stack for Node.js

func (*NodeStack) BaseDistro added in v0.8.0

func (s *NodeStack) BaseDistro() string

func (*NodeStack) Detect

func (s *NodeStack) Detect() bool

func (*NodeStack) GenerateLLB

func (s *NodeStack) GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

func (*NodeStack) Init added in v0.2.0

func (s *NodeStack) Init(opts BuildOptions)

func (*NodeStack) Name

func (s *NodeStack) Name() string

func (*NodeStack) RequiredEnvVars added in v0.8.0

func (s *NodeStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns the detected environment variable requirements

func (*NodeStack) WebCommand added in v0.2.0

func (s *NodeStack) WebCommand() string

type PythonStack

type PythonStack struct {
	MetaStack
	// contains filtered or unexported fields
}

PythonStack implements Stack for Python

func (*PythonStack) BaseDistro added in v0.8.0

func (s *PythonStack) BaseDistro() string

func (*PythonStack) Detect

func (s *PythonStack) Detect() bool

func (*PythonStack) Entrypoint

func (s *PythonStack) Entrypoint() string

func (*PythonStack) GenerateLLB

func (s *PythonStack) GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

func (*PythonStack) Init added in v0.2.0

func (s *PythonStack) Init(opts BuildOptions)

func (*PythonStack) Name

func (s *PythonStack) Name() string

func (*PythonStack) RequiredEnvVars added in v0.8.0

func (s *PythonStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns the detected environment variable requirements

func (*PythonStack) WebCommand added in v0.2.0

func (s *PythonStack) WebCommand() string

type RubyStack

type RubyStack struct {
	MetaStack
	// contains filtered or unexported fields
}

RubyStack implements Stack for Ruby on Rails

func (*RubyStack) BaseDistro added in v0.8.0

func (s *RubyStack) BaseDistro() string

func (*RubyStack) Detect

func (s *RubyStack) Detect() bool

func (*RubyStack) Entrypoint

func (s *RubyStack) Entrypoint() string

func (*RubyStack) Gemfile

func (s *RubyStack) Gemfile() ([]byte, []byte, error)

func (*RubyStack) GenerateLLB

func (s *RubyStack) GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

func (*RubyStack) Init added in v0.2.0

func (s *RubyStack) Init(opts BuildOptions)

func (*RubyStack) Name

func (s *RubyStack) Name() string

func (*RubyStack) RequiredEnvVars added in v0.8.0

func (s *RubyStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns the detected environment variable requirements

func (*RubyStack) WebCommand added in v0.2.0

func (s *RubyStack) WebCommand() string

type RustStack added in v0.2.0

type RustStack struct {
	MetaStack
	// contains filtered or unexported fields
}

RustStack implements Stack for Rust

func (*RustStack) BaseDistro added in v0.8.0

func (s *RustStack) BaseDistro() string

func (*RustStack) Detect added in v0.2.0

func (s *RustStack) Detect() bool

func (*RustStack) GenerateLLB added in v0.2.0

func (s *RustStack) GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

func (*RustStack) Init added in v0.2.0

func (s *RustStack) Init(opts BuildOptions)

func (*RustStack) Name added in v0.2.0

func (s *RustStack) Name() string

func (*RustStack) RequiredEnvVars added in v0.8.0

func (s *RustStack) RequiredEnvVars() []EnvVarRequirement

RequiredEnvVars returns the detected environment variable requirements

func (*RustStack) WebCommand added in v0.2.0

func (s *RustStack) WebCommand() string

type Stack

type Stack interface {
	Name() string
	// Detect returns true if the given directory contains code for this stack
	Detect() bool
	// Init is called after detection to perform common initialization
	Init(opts BuildOptions)
	// GenerateLLB creates the BuildKit LLB for building this stack
	GenerateLLB(dir string, opts BuildOptions) (*llb.State, error)

	Image() ocispecs.Image

	Entrypoint() string

	// WebCommand returns the default command for the web service in a Procfile
	WebCommand() string

	// Events returns detection events collected during Detect() and Init()
	Events() []DetectionEvent

	// RequiredEnvVars returns environment variables detected as required/recommended
	RequiredEnvVars() []EnvVarRequirement

	// BaseDistro returns the package manager family of the stack's base image
	// ("debian" or "alpine"). Used to dispatch apt vs apk for augmentations.
	BaseDistro() string
	// contains filtered or unexported methods
}

Stack represents a programming language/framework stack

func DetectStack

func DetectStack(dir string, opts BuildOptions) (Stack, error)

DetectStack identifies the programming stack in the given directory

Jump to

Keyboard shortcuts

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