bake

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package bake parses mybuild declarative config files.

Supported formats:

  • HCL: kforge.hcl (preferred)
  • JSON: kforge.json

Example kforge.hcl:

variable "TAG" { default = "latest" }

target "app" {
  context    = "."
  dockerfile = "Dockerfile"
  platforms  = ["linux/amd64", "linux/arm64"]
  tags       = ["myrepo/app:${TAG}"]
  cache-from = ["type=registry,ref=myrepo/app:cache"]
  cache-to   = ["type=registry,ref=myrepo/app:cache,mode=max"]
  push       = true
}

group "default" {
  targets = ["app"]
}

Index

Constants

This section is empty.

Variables

View Source
var DefaultFiles = []string{
	"kforge.hcl",
	"kforge.json",
}

DefaultFiles is the lookup order for config files.

Functions

This section is empty.

Types

type File

type File struct {
	Variables []Variable `hcl:"variable,block"`
	Targets   []Target   `hcl:"target,block"`
	Groups    []Group    `hcl:"group,block"`
}

File represents the full parsed config.

func Load

func Load(overrideFile string) (*File, error)

Load finds and parses the first config file that exists. Returns an error if no config file is found.

func (*File) ApplySet

func (f *File) ApplySet(overrides []string) error

ApplySet applies a --set override in the form "target.field=value".

func (*File) ResolveTargets

func (f *File) ResolveTargets(names []string) ([]Target, error)

ResolveTargets returns the list of targets to build. If names is empty it uses the "default" group, falling back to all targets.

type Group

type Group struct {
	Name    string   `hcl:"name,label" json:"name,omitempty"`
	Targets []string `hcl:"targets"    json:"targets"`
}

Group is a named collection of targets.

type Target

type Target struct {
	Name       string   `hcl:"name,label"    json:"name,omitempty"`
	Context    string   `hcl:"context,optional"    json:"context,omitempty"`
	Dockerfile string   `hcl:"dockerfile,optional" json:"dockerfile,omitempty"`
	Platforms  []string `hcl:"platforms,optional"  json:"platforms,omitempty"`
	Tags       []string `hcl:"tags,optional"       json:"tags,omitempty"`
	CacheFrom  []string `hcl:"cache-from,optional" json:"cache-from,omitempty"`
	CacheTo    []string `hcl:"cache-to,optional"   json:"cache-to,omitempty"`
	BuildArgs  []string `hcl:"build-args,optional" json:"build-args,omitempty"`
	Target     string   `hcl:"target,optional"     json:"target,omitempty"`
	Push       bool     `hcl:"push,optional"       json:"push,omitempty"`
	Load       bool     `hcl:"load,optional"       json:"load,omitempty"`
	NoCache    bool     `hcl:"no-cache,optional"   json:"no-cache,omitempty"`
	Secrets    []string `hcl:"secrets,optional"    json:"secrets,omitempty"`
}

Target represents a single build target.

type Variable

type Variable struct {
	Name    string `hcl:"name,label"`
	Default string `hcl:"default,optional"`
}

Variable defines a configurable variable with an optional default.

Jump to

Keyboard shortcuts

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