build

package
v29.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDockerfileName string = "Dockerfile"

DefaultDockerfileName is the Default filename with Docker commands, read by docker build

Deprecated: this const is no longer used and will be removed in the next release.

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 deprecated

func DetectArchiveReader(input io.ReadCloser) (rc io.ReadCloser, ok 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, ok is set to true, and to false otherwise, in which case it is safe to assume input represents the contents of a Dockerfile.

Deprecated: this utility was only used internally, and will be removed in the next release.

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 deprecated

func IsArchive(header []byte) bool

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

Deprecated: this utility was used internally and will be removed in the next release.

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 deprecated

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.

Deprecated: this utility was used internally and will be removed in the next release. Use DetectContextType to detect the context-type, and use GetContextFromLocalDir, GetContextFromLocalDir, GetContextFromGitURL, or GetContextFromURL instead.

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 deprecated

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.

Deprecated: this utility was only used internally, and will be removed in the next release.

Types

type ContextType

type ContextType string

ContextType describes the type (source) of build-context specified.

const (
	ContextTypeStdin  ContextType = "stdin"  // ContextTypeStdin indicates that the build-context is a TAR archive passed through STDIN.
	ContextTypeLocal  ContextType = "local"  // ContextTypeLocal indicates that the build-context is a local directory.
	ContextTypeRemote ContextType = "remote" // ContextTypeRemote indicates that the build-context is a remote URL.
	ContextTypeGit    ContextType = "git"    // ContextTypeGit indicates that the build-context is a GIT URL.
)

func DetectContextType

func DetectContextType(specifiedContext string) (ContextType, error)

DetectContextType detects the type (source) of the build-context.

Directories

Path Synopsis
internal
git
urlutil
Package urlutil provides helper function to check if a given build-context location should be considered a URL or a remote Git repository.
Package urlutil provides helper function to check if a given build-context location should be considered a URL or a remote Git repository.

Jump to

Keyboard shortcuts

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