Documentation ¶
Overview ¶
Package build defines types and interfaces that could potentially be compiled to various external build-tool scripts but share a general internal abstraction and rules for escaping.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶ added in v0.10.0
type Base struct { Image string // image identifier Stage string // optional internal name used for multi-stage builds }
Base is a concrete build instruction for declaring the base container image to start with.
type Copy ¶
type Copy struct { Sources []string // source file/directory paths Destination string // destination path }
Copy is a concrete build instruction for copying source files/directories from the build host into the image.
type CopyAs ¶ added in v0.3.0
type CopyAs struct { UID string // owner UID GID string // owner GID Instruction }
CopyAs is a concrete build instruction for copying source files/directories and setting their ownership to the given UID/GID.
While it can technically wrap any build.Instruction, it is meant to be used with build.Copy and build.CopyFrom to enforce file/directory ownership.
type CopyFrom ¶
CopyFrom is a concrete build instruction for copying source files/directories from one variant image to another.
type EntryPoint ¶ added in v0.3.0
type EntryPoint struct {
Command []string // command and arguments
}
EntryPoint is a build instruction for declaring a container's default runtime process.
func (EntryPoint) Compile ¶ added in v0.3.0
func (ep EntryPoint) Compile() []string
Compile returns the quoted entrypoint command and arguments.
type Env ¶
Env is a concrete build instruction for declaring a container's runtime environment variables.
func Home ¶ added in v0.3.0
Home returns a build.Env instruction for setting the user's home directory.
type Instruction ¶
type Instruction interface {
Compile() []string
}
Instruction defines a common interface that all concrete build types must implement.
func ApplyUser ¶ added in v0.3.0
func ApplyUser(uid string, gid string, instructions []Instruction) []Instruction
ApplyUser wraps any build.Copy instructions as build.CopyAs using the given UID/GID.
type Label ¶
Label is a concrete build instruction for declaring a number of meta-data key/value pairs to be included in the image.
type Phase ¶
type Phase int
Phase enum type
const ( PhasePrivileged Phase = iota // first, copies/execution done as root PhasePrivilegeDropped // second, copies/execution done as unprivileged user from here on PhasePreInstall // third, before application files and artifacts are copied PhaseInstall // fourth, application files and artifacts are copied PhasePostInstall // fifth, after application files and artifacts are copied )
Distinct build phases that each compiler implementation should pass to PhaseCompileable configuration (in the order they are defined here) to allow for dependency injection during compilation.
type PhaseCompileable ¶
type PhaseCompileable interface {
InstructionsForPhase(phase Phase) []Instruction
}
PhaseCompileable defines and interface that all configuration types should implement if they want to inject build instructions into any of the defined build phases.
type Run ¶
type Run struct { Command string // command string (e.g. "useradd -d %s -u %s") Arguments []string // command arguments both inner and final (e.g. ["/home/user", "123", "user"]) }
Run is a concrete build instruction for passing any number of arguments to a shell command.
The command string may contain inner argument placeholders using the "%s" format verb and will be appended with the quoted values of any arguments that remain after interpolation of the command string.
func Chown ¶ added in v0.3.0
Chown returns a build.Run instruction for setting ownership on the given path.
func CreateDirectories ¶ added in v0.5.0
CreateDirectories returns a build.Run instruction for creating all the given directories.
func CreateDirectory ¶ added in v0.3.0
CreateDirectory returns a build.Run instruction for creating the given directory.
func CreateUser ¶ added in v0.3.0
CreateUser returns build.Run instructions for creating the given user account and group.
type RunAll ¶
type RunAll struct {
Runs []Run // multiple Run instructions to be executed together
}
RunAll is a concrete build instruction for declaring multiple Run instructions that will be executed together in a `cmd1 && cmd2` chain.
type ScratchBase ¶ added in v0.10.0
type ScratchBase struct {
Stage string // optional internal name used for multi-stage builds
}
ScratchBase is a concrete build instruction for declaring no base image.
func (ScratchBase) Compile ¶ added in v0.10.0
func (sb ScratchBase) Compile() []string
Compile returns the stage name.
type StringArg ¶ added in v0.10.0
StringArg is a build instruction defining a build-time replaceable argument with a string value.
func NewStringArg ¶ added in v0.10.0
NewStringArg creates an ARG instruction with a string default value.
type UintArg ¶ added in v0.10.0
UintArg is a build instruction defining a build-time replaceable argument with an integer value.
func NewUintArg ¶ added in v0.10.0
NewUintArg creates an ARG instruction with a uint default value.
type User ¶ added in v0.3.0
type User struct {
UID string // user ID
}
User is a build instruction for setting which user will run future commands.
type WorkingDirectory ¶ added in v0.3.0
type WorkingDirectory struct {
Path string // working directory path
}
WorkingDirectory is a build instruction for defining the working directory for future command and entrypoint instructions.
func (WorkingDirectory) Compile ¶ added in v0.3.0
func (wd WorkingDirectory) Compile() []string
Compile returns the quoted working directory path.