This section is empty.


This section is empty.


func FilterArchive

func FilterArchive(r io.Reader, w io.Writer, fn TransformFileFunc) error

    FilterArchive transforms the provided input archive to a new archive, giving the fn a chance to transform arbitrary files.

    func NewClientFromEnv

    func NewClientFromEnv() (*docker.Client, error)

      NewClientFromEnv is exposed to simplify getting a client when vendoring this library.

      func NewLazyArchive

      func NewLazyArchive(fn CreateFileFunc) io.ReadCloser

      func NoAuthFn

      func NoAuthFn(string) ([]dockertypes.AuthConfig, bool)

        NotAuthFn can be used for AuthFn when no authentication is required in Docker.


        type ClientExecutor

        type ClientExecutor struct {
        	// Name is an optional name for this executor.
        	Name string
        	// Named is a map of other named executors.
        	Named map[string]*ClientExecutor
        	// TempDir is the temporary directory to use for storing file
        	// contents. If unset, the default temporary directory for the
        	// system will be used.
        	TempDir string
        	// Client is a client to a Docker daemon.
        	Client *docker.Client
        	// Directory is the context directory to build from, will use
        	// the current working directory if not set. Ignored if
        	// ContextArchive is set.
        	Directory string
        	// A compressed or uncompressed tar archive that should be used
        	// as the build context.
        	ContextArchive string
        	// Excludes are a list of file patterns that should be excluded
        	// from the context. Will be set to the contents of the
        	// .dockerignore file if nil.
        	Excludes []string
        	// Tag is an optional value to tag the resulting built image.
        	Tag string
        	// Additional tags is an optional array of other tags to apply
        	// to the image.
        	AdditionalTags []string
        	// AllowPull when set will pull images that are not present on
        	// the daemon.
        	AllowPull bool
        	// IgnoreUnrecognizedInstructions, if true, allows instructions
        	// that are not yet supported to be ignored (will be printed)
        	IgnoreUnrecognizedInstructions bool
        	// StrictVolumeOwnership if true will fail the build if a RUN
        	// command follows a VOLUME command, since this client cannot
        	// guarantee that the restored contents of the VOLUME directory
        	// will have the right permissions.
        	StrictVolumeOwnership bool
        	// TransientMounts are a set of mounts from outside the build
        	// to the inside that will not be part of the final image. Any
        	// content created inside the mount's destinationPath will be
        	// omitted from the final image.
        	TransientMounts []Mount
        	// The path within the container to perform the transient mount.
        	ContainerTransientMount string
        	// The streams used for canonical output.
        	Out, ErrOut io.Writer
        	// Container is optional and can be set to a container to use as
        	// the execution environment for a build.
        	Container *docker.Container
        	// Command, if set, will be used as the entrypoint for the new
        	// container. This is ignored if Container is set.
        	Command []string
        	// Image is optional and may be set to control which image is used
        	// as a base for this build. Otherwise the FROM value from the
        	// Dockerfile is read (will be pulled if not locally present).
        	Image *docker.Image
        	// AuthFn will handle authenticating any docker pulls if Image
        	// is set to nil.
        	AuthFn func(name string) ([]dockertypes.AuthConfig, bool)
        	// HostConfig is used to start the container (if necessary).
        	HostConfig *docker.HostConfig
        	// LogFn is an optional command to log information to the end user
        	LogFn func(format string, args ...interface{})
        	// Deferred is a list of operations that must be cleaned up at
        	// the end of execution. Use Release() to handle these.
        	Deferred []func() error
        	// Volumes handles saving and restoring volumes after RUN
        	// commands are executed.
        	Volumes *ContainerVolumeTracker

          ClientExecutor can run Docker builds from a Docker client.

          func NewClientExecutor

          func NewClientExecutor(client *docker.Client) *ClientExecutor

            NewClientExecutor creates a client executor.

            func (*ClientExecutor) Archive

            func (e *ClientExecutor) Archive(fromFS bool, src, dst string, allowDownload bool, excludes []string) (io.Reader, io.Closer, error)

              TODO: this does not support decompressing nested archives for ADD (when the source is a compressed file)

              func (*ClientExecutor) Build

              func (e *ClientExecutor) Build(b *imagebuilder.Builder, node *parser.Node, from string) error

                Build is a helper method to perform a Docker build against the provided Docker client. It will load the image if not specified, create a container if one does not already exist, and start a container if the Dockerfile contains RUN commands. It will cleanup any containers it creates directly, and set the e.Image.ID field to the generated image.

                func (*ClientExecutor) Commit

                func (e *ClientExecutor) Commit(b *imagebuilder.Builder) error

                  Commit saves the completed build as an image with the provided tag. It will stop the container, commit the image, and then remove the container.

                  func (*ClientExecutor) Copy

                  func (e *ClientExecutor) Copy(excludes []string, copies ...imagebuilder.Copy) error

                    Copy implements the executor copy function.

                    func (*ClientExecutor) CopyContainer

                    func (e *ClientExecutor) CopyContainer(container *docker.Container, excludes []string, copies ...imagebuilder.Copy) error

                      CopyContainer copies the provided content into a destination container.

                      func (*ClientExecutor) CreateScratchImage

                      func (e *ClientExecutor) CreateScratchImage() (string, error)

                        CreateScratchImage creates a new, zero byte layer that is identical to "scratch" except that the resulting image will have two layers.

                        func (*ClientExecutor) DefaultExcludes

                        func (e *ClientExecutor) DefaultExcludes() error

                        func (*ClientExecutor) EnsureContainerPath

                        func (e *ClientExecutor) EnsureContainerPath(path string) error

                        func (*ClientExecutor) Execute

                        func (e *ClientExecutor) Execute(b *imagebuilder.Builder, node *parser.Node) error

                          Execute performs all of the provided steps against the initialized container. May be invoked multiple times for a given container.

                          func (*ClientExecutor) LoadImage

                          func (e *ClientExecutor) LoadImage(from string) (*docker.Image, error)

                            LoadImage checks the client for an image matching from. If not found, attempts to pull the image and then tries to inspect again.

                            func (*ClientExecutor) PopulateTransientMounts

                            func (e *ClientExecutor) PopulateTransientMounts(opts docker.CreateContainerOptions, transientMounts []Mount, sharedMount string) ([]string, error)

                            func (*ClientExecutor) Prepare

                            func (e *ClientExecutor) Prepare(b *imagebuilder.Builder, node *parser.Node, from string) error

                            func (*ClientExecutor) Preserve

                            func (e *ClientExecutor) Preserve(path string) error

                            func (*ClientExecutor) Release

                            func (e *ClientExecutor) Release() []error

                              Release deletes any items started by this executor.

                              func (*ClientExecutor) Run

                              func (e *ClientExecutor) Run(run imagebuilder.Run, config docker.Config) error

                                Run executes a single Run command against the current container using exec(). Since exec does not allow ENV or WORKINGDIR to be set, we force the execution of the user command into a shell and perform those operations before. Since RUN requires /bin/sh, we can use both 'cd' and 'export'.

                                func (*ClientExecutor) Stages

                                  Stages executes all of the provided stages, starting from the base image. It returns the executor of the last stage or an error if a stage fails.

                                  func (*ClientExecutor) UnrecognizedInstruction

                                  func (e *ClientExecutor) UnrecognizedInstruction(step *imagebuilder.Step) error

                                  func (*ClientExecutor) WithName

                                  func (e *ClientExecutor) WithName(name string) *ClientExecutor

                                    WithName creates a new child executor that will be used whenever a COPY statement uses --from=NAME.

                                    type ContainerVolumeTracker

                                    type ContainerVolumeTracker struct {
                                    	// contains filtered or unexported fields

                                      ContainerVolumeTracker manages tracking archives of specific paths inside a container.

                                      func NewContainerVolumeTracker

                                      func NewContainerVolumeTracker() *ContainerVolumeTracker

                                      func (*ContainerVolumeTracker) Add

                                      func (t *ContainerVolumeTracker) Add(path string)

                                        Add tracks path unless it already is being tracked.

                                        func (*ContainerVolumeTracker) Empty

                                        func (t *ContainerVolumeTracker) Empty() bool

                                          Empty returns true if the tracker is not watching any paths

                                          func (*ContainerVolumeTracker) Invalidate

                                          func (t *ContainerVolumeTracker) Invalidate(path string)

                                          func (*ContainerVolumeTracker) Release

                                          func (t *ContainerVolumeTracker) Release() []error

                                            Release removes any stored snapshots

                                            func (*ContainerVolumeTracker) ReleasePath

                                            func (t *ContainerVolumeTracker) ReleasePath(path string)

                                            func (*ContainerVolumeTracker) Restore

                                            func (t *ContainerVolumeTracker) Restore(containerID string, client *docker.Client) error

                                              Restore ensures the paths managed by t exactly match the container. This requires running exec as a user that can delete contents from the container. It will return an error if any client operation fails.

                                              func (*ContainerVolumeTracker) Save

                                              func (t *ContainerVolumeTracker) Save(containerID, tempDir string, client *docker.Client) error

                                                Save ensures that all paths tracked underneath this container are archived or returns an error.

                                                type CopyInfo

                                                type CopyInfo struct {
                                                	Path       string
                                                	Decompress bool
                                                	FromDir    bool

                                                func CalcCopyInfo

                                                func CalcCopyInfo(origPath, rootPath string, allowWildcards bool) ([]CopyInfo, error)

                                                  CalcCopyInfo identifies the source files selected by a Dockerfile ADD or COPY instruction.

                                                  func DownloadURL

                                                  func DownloadURL(src, dst, tempDir string) ([]CopyInfo, string, error)

                                                  type CreateFileFunc

                                                  type CreateFileFunc func() (*tar.Header, io.ReadCloser, bool, error)

                                                  type DirectoryCheck

                                                  type DirectoryCheck interface {
                                                  	IsDirectory(path string) (bool, error)

                                                  type Mount

                                                  type Mount struct {
                                                  	SourcePath      string
                                                  	DestinationPath string

                                                    Mount represents a binding between the current system and the destination client

                                                    type TransformFileFunc

                                                    type TransformFileFunc func(h *tar.Header, r io.Reader) (data []byte, update bool, skip bool, err error)

                                                      TransformFileFunc is given a chance to transform an arbitrary input file.