Documentation ¶
Overview ¶
Package builder uses code from github.com/docker/docker/builder/* to implement a Docker builder that does not create individual layers, but instead creates a single layer.
TODO: full windows support
Index ¶
- Constants
- Variables
- func BashQuote(env string) string
- func ExportEnv(env []string) string
- func ParseDockerfile(r io.Reader) (*parser.Node, error)
- func ParseDockerignore(root string) ([]string, error)
- func ParseFile(path string) (*parser.Node, error)
- func ParseIgnore(path string) ([]string, error)
- func ProcessWord(word string, env []string) (string, error)
- func ProcessWords(word string, env []string) ([]string, error)
- func SplitBy(node *parser.Node, value string) []*parser.Node
- func SplitChildren(node *parser.Node, value string) []*parser.Node
- type Builder
- func (b *Builder) Arguments() []string
- func (b *Builder) Config() *docker.Config
- func (b *Builder) From(node *parser.Node) (string, error)
- func (b *Builder) FromImage(image *docker.Image, node *parser.Node) error
- func (b *Builder) RequiresStart(node *parser.Node) bool
- func (b *Builder) Run(step *Step, exec Executor, noRunsRemaining bool) error
- func (b *Builder) Step() *Step
- type Copy
- type Executor
- type Run
- type Stage
- type Stages
- type Step
- type StepFunc
- type VolumeSet
Constants ¶
const (
// in docker/system
NoBaseImageSpecifier = "scratch"
)
Variables ¶
var ( LogExecutor = logExecutor{} NoopExecutor = noopExecutor{} )
var ErrNoFROM = fmt.Errorf("no FROM statement found")
ErrNoFROM is returned if the Dockerfile did not contain a FROM statement.
Functions ¶
func BashQuote ¶
BashQuote escapes the provided string and surrounds it with double quotes. TODO: verify that these are all we have to escape.
func ExportEnv ¶
ExportEnv creates an export statement for a shell that contains all of the provided environment.
func ParseDockerfile ¶
ParseDockerfile parses the provided stream as a canonical Dockerfile
func ParseDockerignore ¶
ParseDockerIgnore returns a list of the excludes in the .containerignore or .dockerignore file.
func ParseIgnore ¶ added in v1.2.0
ParseIgnore returns a list of the excludes in the specified path path should be a file with the .dockerignore format extracted from fsouza/go-dockerclient and modified to drop comments and empty lines.
func ProcessWord ¶
ProcessWord will use the 'env' list of environment variables, and replace any env var references in 'word'.
func ProcessWords ¶
ProcessWords will use the 'env' list of environment variables, and replace any env var references in 'word' then it will also return a slice of strings which represents the 'word' split up based on spaces - taking into account quotes. Note that this splitting is done **after** the env var substitutions are done. Note, each one is trimmed to remove leading and trailing spaces (unless they are quoted", but ProcessWord retains spaces between words.
Types ¶
type Builder ¶
type Builder struct { RunConfig docker.Config Env []string Args map[string]string HeadingArgs map[string]string UserArgs map[string]string CmdSet bool Author string // Certain instructions like `FROM` will need to use // `ARG` decalred before or not in this stage hence // while processing instruction like `FROM ${SOME_ARG}` // we will make sure to verify if they are declared any // where in containerfile or not. GlobalAllowedArgs []string AllowedArgs map[string]bool Volumes VolumeSet Excludes []string PendingVolumes VolumeSet PendingRuns []Run PendingCopies []Copy Warnings []string // Raw platform string specified with `FROM --platform` of the stage // It's up to the implementation or client to parse and use this field Platform string }
func NewBuilder ¶
func (*Builder) Config ¶
Config returns a snapshot of the current RunConfig intended for use with a container commit.
func (*Builder) From ¶
From returns the image this dockerfile depends on, or an error if no FROM is found or if multiple FROM are specified. If a single from is found the passed node is updated with only the remaining statements. The builder's RunConfig.Image field is set to the first From found, or left unchanged if already set.
func (*Builder) FromImage ¶
FromImage updates the builder to use the provided image (resetting RunConfig and recording the image environment), and updates the node with any ONBUILD statements extracted from the parent image.
func (*Builder) RequiresStart ¶
RequiresStart returns true if a running container environment is necessary to invoke the provided commands
type Copy ¶
type Copy struct { // If true, this is a copy from the file system to the container. If false, // the copy is from the context. FromFS bool // If set, this is a copy from the named stage or image to the container. From string Src []string Dest string Download bool // If set, the owner:group for the destination. This value is passed // to the executor for handling. Chown string Chmod string }
Copy defines a copy operation required on the container.
type Executor ¶
type Executor interface { Preserve(path string) error // EnsureContainerPath should ensure that the directory exists, creating any components required EnsureContainerPath(path string) error // EnsureContainerPathAs should ensure that the directory exists, creating any components required // with the specified owner and mode, if either is specified EnsureContainerPathAs(path, user string, mode *os.FileMode) error Copy(excludes []string, copies ...Copy) error Run(run Run, config docker.Config) error UnrecognizedInstruction(step *Step) error }
type Run ¶
type Run struct { Shell bool Args []string // Mounts are mounts specified through the --mount flag inside the Containerfile Mounts []string // Network specifies the network mode to run the container with Network string }
Run defines a run operation required in the container.
type Step ¶
type Step struct { Env []string Command string Args []string Flags []string Attrs map[string]bool Message string Original string }
Step represents the input Env and the output command after all post processing of the command arguments is done.
func (*Step) Resolve ¶
Resolve transforms a parsed Dockerfile line into a command to execute, resolving any arguments.
Almost all nodes will have this structure: Child[Node, Node, Node] where Child is from parser.Node.Children and each node comes from parser.Node.Next. This forms a "line" with a statement and arguments and we process them in this normalized form by hitting evaluateTable with the leaf nodes of the command and the Builder object.
ONBUILD is a special case; in this case the parser will emit: Child[Node, Child[Node, Node...]] where the first node is the literal "onbuild" and the child entrypoint is the command of the ONBUILD statement, such as `RUN` in ONBUILD RUN foo. There is special case logic in here to deal with that, at least until it becomes more of a general concern with new features.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
dockerfile
|
|
command
Package command contains the set of Dockerfile commands.
|
Package command contains the set of Dockerfile commands. |
parser
Package parser implements a parser and parse tree dumper for Dockerfiles.
|
Package parser implements a parser and parse tree dumper for Dockerfiles. |
Package signal provides helper functions for dealing with signals across various operating systems.
|
Package signal provides helper functions for dealing with signals across various operating systems. |