plan

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package plan converts a detected Framework into an abstract BuildPlan. It selects base images, build stages, hardening steps (non-root user, tini, health checks, distroless), and BuildKit cache mounts based on the runtime. Plans are pure data — no I/O, no side effects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySecretMounts

func ApplySecretMounts(plan *core.BuildPlan, dir string) []detect.SecretDef

ApplySecretMounts detects private registry usage in dir and wires BuildKit secret mounts into the appropriate install step of the plan. Returns the list of secrets applied (empty if none detected).

func BuildkitCacheArgs

func BuildkitCacheArgs(appID string) []string

BuildkitCacheArgs returns --cache-from and --cache-to flags for buildctl/docker buildx.

func CacheDir

func CacheDir(appID string) string

CacheDir returns the BuildKit cache directory for an app. The appID is sanitized to prevent path traversal.

func FrameworkDefaults

func FrameworkDefaults(name string) (buildCmd, startCmd string)

FrameworkDefaults returns sensible build and start commands for a framework. Returns empty strings for unknown frameworks.

func Plan

func Plan(fw *core.Framework, opts ...PlanOption) (*core.BuildPlan, error)

Plan converts a detected Framework into a BuildPlan. Options are applied after the plan is built, overriding defaults.

func ResolveDockerTag

func ResolveDockerTag(runtime, version string) string

func SanitizeAppID

func SanitizeAppID(appID string) string

SanitizeAppID makes an app ID safe for use in file paths.

func SecretBuildHint

func SecretBuildHint(secrets []detect.SecretDef) string

SecretBuildHint returns a Dockerfile comment documenting the docker build invocation needed to supply secrets. Returns "" when no secrets are present.

func SecretIgnoreFiles

func SecretIgnoreFiles() []string

SecretIgnoreFiles returns file patterns that should be added to .dockerignore when secrets are detected, preventing credential files from leaking into the build context.

Types

type PlanConfig

type PlanConfig struct {
	User         *string
	Healthcheck  *string
	RuntimeImage *string
	BaseImage    *string
	Entrypoint   []string
	ExtraEnv     map[string]string
	Expose       *int
	InstallCmd   *string
	BuildCmd     *string
	StartCmd     *string
	SystemDeps   []string
	NoBuildCache bool
	Secrets      []core.SecretMount
	ContextRoot  *string
}

PlanConfig holds user-specified overrides for Plan(). A nil pointer means "not set — use default". A non-nil pointer (even &"") means "explicitly set — use this value, possibly disabling the feature".

func ResolvePlanConfig

func ResolvePlanConfig(opts []PlanOption) *PlanConfig

ResolvePlanConfig resolves a slice of PlanOption into a PlanConfig.

type PlanOption

type PlanOption interface {
	// contains filtered or unexported methods
}

PlanOption modifies a planConfig.

func WithBaseImage

func WithBaseImage(image string) PlanOption

func WithBuildCacheDisabled

func WithBuildCacheDisabled() PlanOption

func WithBuildCommand

func WithBuildCommand(cmd string) PlanOption

WithBuildCommand overrides the build step command. This is a no-op for single-stage plans that have no explicit "build" stage.

func WithContextRoot

func WithContextRoot(appSubdir string) PlanOption

func WithEntrypoint

func WithEntrypoint(args ...string) PlanOption

func WithExpose

func WithExpose(port int) PlanOption

func WithExtraEnv

func WithExtraEnv(env map[string]string) PlanOption

func WithHealthcheck

func WithHealthcheck(cmd string) PlanOption

func WithHealthcheckDisabled

func WithHealthcheckDisabled() PlanOption

func WithInstallCommand

func WithInstallCommand(cmd string) PlanOption

func WithRuntimeImage

func WithRuntimeImage(image string) PlanOption

func WithSecrets

func WithSecrets(secrets []core.SecretMount) PlanOption

func WithStartCommand

func WithStartCommand(cmd string) PlanOption

func WithSystemDeps

func WithSystemDeps(deps ...string) PlanOption

func WithUser

func WithUser(user string) PlanOption

Jump to

Keyboard shortcuts

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