builder

package
v1.7.1-ros-1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2015 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

Package builder is the evaluation step in the Dockerfile parse/evaluate pipeline.

It incorporates a dispatch table based on the parser.Node values (see the parser package for more information) that are yielded from the parser itself. Calling NewBuilder with the BuildOpts struct can be used to customize the experience for execution purposes only. Parsing is controlled in the parser package, and this division of resposibility should be respected.

Please see the jump table targets for the actual invocations, most of which will call out to the functions in internals.go to deal with their tasks.

ONBUILD is a special case, which is covered in the onbuild() func in dispatchers.go.

The evaluator uses the concept of "steps", which are usually each processable line in the Dockerfile. Each step is numbered and certain actions are taken before and after each step, such as creating an image ID and removing temporary containers and images. Note that ONBUILD creates a kinda-sorta "sub run" which includes its own set of steps (usually only one of them).

Index

Constants

View Source
const (
	// NoBaseImageSpecifier is the symbol used by the FROM
	// command to specify that no base image is to be used.
	NoBaseImageSpecifier string = "scratch"
)

Variables

This section is empty.

Functions

func Build added in v1.7.0

func Build(d *daemon.Daemon, buildConfig *Config) error

func BuildFromConfig added in v1.7.0

func BuildFromConfig(d *daemon.Daemon, c *runconfig.Config, changes []string) (*runconfig.Config, error)

func Commit added in v1.7.0

func ContainsWildcards

func ContainsWildcards(name string) bool

func ProcessWord added in v1.6.0

func ProcessWord(word string, env []string) (string, error)

Types

type Builder

type Builder struct {
	Daemon *daemon.Daemon

	// effectively stdio for the run. Because it is not stdio, I said
	// "Effectively". Do not use stdio anywhere in this package for any reason.
	OutStream io.Writer
	ErrStream io.Writer

	Verbose      bool
	UtilizeCache bool

	// controls how images and containers are handled between steps.
	Remove      bool
	ForceRemove bool
	Pull        bool

	// Registry server auth configs used to pull images when handling `FROM`.
	AuthConfigs map[string]cliconfig.AuthConfig

	// Deprecated, original writer used for ImagePull. To be removed.
	OutOld          io.Writer
	StreamFormatter *streamformatter.StreamFormatter

	Config *runconfig.Config // runconfig for cmd, run, entrypoint etc.

	// both of these are controlled by the Remove and ForceRemove options in BuildOpts
	TmpContainers map[string]struct{} // a map of containers used for removes

	BuilderFlags *BuilderFlags // current cmd's BuilderFlags - temporary
	// contains filtered or unexported fields
}

internal struct, used to maintain configuration of the Dockerfile's processing as it evaluates the parsing result.

func (*Builder) Run

func (b *Builder) Run(context io.Reader) (string, error)

Run the builder with the context. This is the lynchpin of this package. This will (barring errors):

  • call readContext() which will set up the temporary directory and unpack the context into it.
  • read the dockerfile
  • parse the dockerfile
  • walk the parse tree and execute it by dispatching to handlers. If Remove or ForceRemove is set, additional cleanup around containers happens after processing.
  • Print a happy message and return the image ID.

type BuilderFlags added in v1.7.0

type BuilderFlags struct {
	Args []string // actual flags/args from cmd line

	Err error
	// contains filtered or unexported fields
}

func NewBuilderFlags added in v1.7.0

func NewBuilderFlags() *BuilderFlags

func (*BuilderFlags) AddBool added in v1.7.0

func (bf *BuilderFlags) AddBool(name string, def bool) *Flag

func (*BuilderFlags) AddString added in v1.7.0

func (bf *BuilderFlags) AddString(name string, def string) *Flag

func (*BuilderFlags) Parse added in v1.7.0

func (bf *BuilderFlags) Parse() error

type Config added in v1.7.0

type Config struct {
	DockerfileName string
	RemoteURL      string
	RepoName       string
	SuppressOutput bool
	NoCache        bool
	Remove         bool
	ForceRemove    bool
	Pull           bool
	Memory         int64
	MemorySwap     int64
	CpuShares      int64
	CpuPeriod      int64
	CpuQuota       int64
	CpuSetCpus     string
	CpuSetMems     string
	CgroupParent   string
	AuthConfigs    map[string]cliconfig.AuthConfig

	Stdout  io.Writer
	Context io.ReadCloser
	// contains filtered or unexported fields
}

func NewBuildConfig added in v1.7.0

func NewBuildConfig() *Config

func (*Config) Cancel added in v1.7.0

func (b *Config) Cancel()

When called, causes the Job.WaitCancelled channel to unblock.

func (*Config) WaitCancelled added in v1.7.0

func (b *Config) WaitCancelled() <-chan struct{}

Returns a channel which is closed ("never blocks") when the job is cancelled.

type Flag added in v1.7.0

type Flag struct {
	Value string
	// contains filtered or unexported fields
}

func (*Flag) IsTrue added in v1.7.0

func (fl *Flag) IsTrue() bool

func (*Flag) IsUsed added in v1.7.0

func (fl *Flag) IsUsed() bool

type FlagType added in v1.7.0

type FlagType int

Directories

Path Synopsis
This package contains the set of Dockerfile commands.
This package contains the set of Dockerfile commands.
This package implements a parser and parse tree dumper for Dockerfiles.
This package implements a parser and parse tree dumper for Dockerfiles.

Jump to

Keyboard shortcuts

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