build

package
v20.10.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDockerfileName is the Default filename with Docker commands, read by docker build
	DefaultDockerfileName string = "Dockerfile"
)

Variables

This section is empty.

Functions

func AddDockerfileToBuildContext

func AddDockerfileToBuildContext(dockerfileCtx io.ReadCloser, buildCtx io.ReadCloser) (io.ReadCloser, string, error)

AddDockerfileToBuildContext from a ReadCloser, returns a new archive and the relative path to the dockerfile in the context.

func Compress

func Compress(buildCtx io.ReadCloser) (io.ReadCloser, error)

Compress the build context for sending to the API

func DetectArchiveReader

func DetectArchiveReader(input io.ReadCloser) (rc io.ReadCloser, isArchive bool, err error)

DetectArchiveReader detects whether the input stream is an archive or a Dockerfile and returns a buffered version of input, safe to consume in lieu of input. If an archive is detected, isArchive is set to true, and to false otherwise, in which case it is safe to assume input represents the contents of a Dockerfile.

func GetContextFromGitURL

func GetContextFromGitURL(gitURL, dockerfileName string) (string, string, error)

GetContextFromGitURL uses a Git URL as context for a `docker build`. The git repo is cloned into a temporary directory used as the context directory. Returns the absolute path to the temporary context directory, the relative path of the dockerfile in that context directory, and a non-nil error on success.

func GetContextFromLocalDir

func GetContextFromLocalDir(localDir, dockerfileName string) (string, string, error)

GetContextFromLocalDir uses the given local directory as context for a `docker build`. Returns the absolute path to the local context directory, the relative path of the dockerfile in that context directory, and a non-nil error on success.

func GetContextFromReader

func GetContextFromReader(rc io.ReadCloser, dockerfileName string) (out io.ReadCloser, relDockerfile string, err error)

GetContextFromReader will read the contents of the given reader as either a Dockerfile or tar archive. Returns a tar archive used as a context and a path to the Dockerfile inside the tar.

func GetContextFromURL

func GetContextFromURL(out io.Writer, remoteURL, dockerfileName string) (io.ReadCloser, string, error)

GetContextFromURL uses a remote URL as context for a `docker build`. The remote resource is downloaded as either a Dockerfile or a tar archive. Returns the tar archive used for the context and a path of the dockerfile inside the tar.

func IsArchive

func IsArchive(header []byte) bool

IsArchive checks for the magic bytes of a tar or any supported compression algorithm.

func ReadDockerignore

func ReadDockerignore(contextDir string) ([]string, error)

ReadDockerignore reads the .dockerignore file in the context directory and returns the list of paths to exclude

func ResolveAndValidateContextPath

func ResolveAndValidateContextPath(givenContextDir string) (string, error)

ResolveAndValidateContextPath uses the given context directory for a `docker build` and returns the absolute path to the context directory.

func TrimBuildFilesFromExcludes

func TrimBuildFilesFromExcludes(excludes []string, dockerfile string, dockerfileFromStdin bool) []string

TrimBuildFilesFromExcludes removes the named Dockerfile and .dockerignore from the list of excluded files. The daemon will remove them from the final context but they must be in available in the context when passed to the API.

func ValidateContextDirectory

func ValidateContextDirectory(srcPath string, excludes []string) error

ValidateContextDirectory checks if all the contents of the directory can be read and returns an error if some files can't be read symlinks which point to non-existing files don't trigger an error

func WriteTempDockerfile

func WriteTempDockerfile(rc io.ReadCloser) (dockerfileDir string, err error)

WriteTempDockerfile writes a Dockerfile stream to a temporary file with a name specified by DefaultDockerfileName and returns the path to the temporary directory containing the Dockerfile.

Types

This section is empty.

Jump to

Keyboard shortcuts

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