Documentation ¶
Index ¶
- Variables
- func CanonicalTarNameForPath(p string) (string, error)
- func CompareConfigs(a, b docker.Config) bool
- func NewColoredContainerFormatter() log.Formatter
- func NewMonochromeContainerFormatter() log.Formatter
- func ReadDockerignore(r io.Reader) ([]string, error)
- func ReadDockerignoreFile(file string) ([]string, error)
- type Build
- type Cache
- type CacheFS
- type Client
- type Command
- type CommandAdd
- type CommandArg
- type CommandAttach
- type CommandBase
- type CommandCleanup
- type CommandCmd
- type CommandCommit
- type CommandCopy
- type CommandEntrypoint
- type CommandEnv
- type CommandExport
- type CommandExpose
- type CommandFrom
- type CommandImport
- type CommandLabel
- type CommandMaintainer
- type CommandMount
- type CommandOnbuild
- type CommandOnbuildWrap
- type CommandPush
- type CommandRun
- type CommandTag
- type CommandUser
- type CommandVolume
- type CommandWorkdir
- type Config
- type ConfigCommand
- type DockerClient
- func (c *DockerClient) CommitContainer(s *State) (*docker.Image, error)
- func (c *DockerClient) CreateContainer(s State) (string, error)
- func (c *DockerClient) EnsureContainer(containerName string, config *docker.Config, hostConfig *docker.HostConfig, ...) (containerID string, err error)
- func (c *DockerClient) EnsureImage(imageName string) (err error)
- func (c *DockerClient) InspectContainer(containerName string) (container *docker.Container, err error)
- func (c *DockerClient) InspectImage(name string) (img *docker.Image, err error)
- func (c *DockerClient) ListImageTags(name string) (images []*imagename.ImageName, err error)
- func (c *DockerClient) ListImages() (images []*imagename.ImageName, err error)
- func (c *DockerClient) PullImage(name string) error
- func (c *DockerClient) PushImage(imageName string) (digest string, err error)
- func (c *DockerClient) RemoveContainer(containerID string) error
- func (c *DockerClient) RemoveImage(imageID string) error
- func (c *DockerClient) ResolveHostPath(path string) (resultPath string, err error)
- func (c *DockerClient) RunContainer(containerID string, attachStdin bool) error
- func (c *DockerClient) TagImage(imageID, imageName string) error
- func (c *DockerClient) UploadToContainer(containerID string, stream io.Reader, path string) error
- type DockerClientOptions
- type EnvReplacableCommand
- type Plan
- type Rockerfile
- type State
- type StateNoCache
- type URLFetcher
- type URLFetcherFS
- type URLInfo
Constants ¶
This section is empty.
Variables ¶
var ( // NoBaseImageSpecifier defines the empty image name, used in the FROM instruction NoBaseImageSpecifier = "scratch" // MountVolumeImage used for MOUNT volume containers MountVolumeImage = "grammarly/scratch:latest" // RsyncImage used for EXPORT volume containers RsyncImage = "grammarly/rsync-static:1" // ExportsPath is the path within EXPORT volume containers ExportsPath = "/.rocker_exports" // DefaultPathEnv is a system PATH variable to be used in Env substitutions // if path is not set by ENV command DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" )
Functions ¶
func CanonicalTarNameForPath ¶
CanonicalTarNameForPath returns platform-specific filepath to canonical posix-style path for tar archival. p is relative path.
func CompareConfigs ¶
func CompareConfigs(a, b docker.Config) bool
CompareConfigs compares two Config struct. Does not compare the "Image" nor "Hostname" fields If OpenStdin is set, then it differs
func NewColoredContainerFormatter ¶
NewColoredContainerFormatter Returns Formatter that makes your messages outputed without any log-related data. Also, this formatter will make all messages colored (RED for now). Usefull when you want all stderr messages from container to become more noticible
func NewMonochromeContainerFormatter ¶
NewMonochromeContainerFormatter Returns Formatter that makes your messages outputed without any log-related data.
func ReadDockerignore ¶
ReadDockerignore reads and parses .dockerignore file from io.Reader
func ReadDockerignoreFile ¶
ReadDockerignoreFile reads and parses .dockerignore file
Types ¶
type Build ¶
type Build struct { ProducedSize int64 VirtualSize int64 // contains filtered or unexported fields }
Build is the main object that processes build
func New ¶
func New(client Client, rockerfile *Rockerfile, cache Cache, cfg Config) *Build
New creates the new build object
func (*Build) GetImageID ¶
GetImageID returns last image ID produced by the build
type CacheFS ¶
type CacheFS struct {
// contains filtered or unexported fields
}
CacheFS implements file based cache backend
func NewCacheFS ¶
NewCacheFS creates a file based cache backend
type Client ¶
type Client interface { InspectImage(name string) (*docker.Image, error) PullImage(name string) error ListImages() (images []*imagename.ImageName, err error) ListImageTags(name string) (images []*imagename.ImageName, err error) RemoveImage(imageID string) error TagImage(imageID, imageName string) error PushImage(imageName string) (digest string, err error) EnsureImage(imageName string) error CreateContainer(state State) (id string, err error) RunContainer(containerID string, attachStdin bool) error CommitContainer(state *State) (img *docker.Image, err error) RemoveContainer(containerID string) error UploadToContainer(containerID string, stream io.Reader, path string) error EnsureContainer(containerName string, config *docker.Config, hostConfig *docker.HostConfig, purpose string) (containerID string, err error) InspectContainer(containerName string) (*docker.Container, error) ResolveHostPath(path string) (resultPath string, err error) }
Client interface
type Command ¶
type Command interface { // Execute does the command execution and returns modified state. // Note that here we use State not by reference because we want // it to be immutable. In future, it may encoded/decoded from json // and passed to the external command implementations. Execute(b *Build) (State, error) // Returns true if the command should be executed ShouldRun(b *Build) (bool, error) // String returns the human readable string representation of the command String() string }
Command interface describes and command that is executed by build
func NewCommand ¶
func NewCommand(cfg ConfigCommand) (cmd Command)
NewCommand make a new command according to the configuration given
type CommandAdd ¶
type CommandAdd struct {
CommandBase
}
CommandAdd implements ADD For now it is an alias of COPY, but later will add urls and archives to it
func (*CommandAdd) Execute ¶
func (c *CommandAdd) Execute(b *Build) (State, error)
Execute runs the command
func (*CommandAdd) ReplaceEnv ¶
func (c *CommandAdd) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandBase ¶
type CommandBase struct {
// contains filtered or unexported fields
}
CommandBase implements base command that includes ConfigCommand and always run without a precondition
func (*CommandBase) ShouldRun ¶
func (c *CommandBase) ShouldRun(b *Build) (bool, error)
ShouldRun returns true if the command should be executed
func (*CommandBase) String ¶
func (c *CommandBase) String() string
String returns the human readable string representation of the command
type CommandCleanup ¶
type CommandCleanup struct {
// contains filtered or unexported fields
}
CommandCleanup cleans the builder state before the next FROM
func (*CommandCleanup) Execute ¶
func (c *CommandCleanup) Execute(b *Build) (State, error)
Execute runs the command
func (*CommandCleanup) ShouldRun ¶
func (c *CommandCleanup) ShouldRun(b *Build) (bool, error)
ShouldRun returns true if the command should be executed
func (*CommandCleanup) String ¶
func (c *CommandCleanup) String() string
String returns the human readable string representation of the command
type CommandCommit ¶
type CommandCommit struct{}
CommandCommit commits collected changes
func (*CommandCommit) Execute ¶
func (c *CommandCommit) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandCommit) ShouldRun ¶
func (c *CommandCommit) ShouldRun(b *Build) (bool, error)
ShouldRun returns true if the command should be executed
func (*CommandCommit) String ¶
func (c *CommandCommit) String() string
String returns the human readable string representation of the command
type CommandCopy ¶
type CommandCopy struct {
CommandBase
}
CommandCopy implements COPY
func (*CommandCopy) Execute ¶
func (c *CommandCopy) Execute(b *Build) (State, error)
Execute runs the command
func (*CommandCopy) ReplaceEnv ¶
func (c *CommandCopy) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandEntrypoint ¶
type CommandEntrypoint struct {
CommandBase
}
CommandEntrypoint implements ENTRYPOINT
type CommandEnv ¶
type CommandEnv struct {
CommandBase
}
CommandEnv implements ENV
func (*CommandEnv) Execute ¶
func (c *CommandEnv) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandEnv) ReplaceEnv ¶
func (c *CommandEnv) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandExpose ¶
type CommandExpose struct {
CommandBase
}
CommandExpose implements EXPOSE
func (*CommandExpose) Execute ¶
func (c *CommandExpose) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandExpose) ReplaceEnv ¶
func (c *CommandExpose) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandLabel ¶
type CommandLabel struct {
CommandBase
}
CommandLabel implements LABEL
func (*CommandLabel) Execute ¶
func (c *CommandLabel) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandLabel) ReplaceEnv ¶
func (c *CommandLabel) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandMaintainer ¶
type CommandMaintainer struct {
CommandBase
}
CommandMaintainer implements CMD
type CommandOnbuildWrap ¶
type CommandOnbuildWrap struct {
// contains filtered or unexported fields
}
CommandOnbuildWrap wraps ONBUILD command
func (*CommandOnbuildWrap) Execute ¶
func (c *CommandOnbuildWrap) Execute(b *Build) (State, error)
Execute runs the command
func (*CommandOnbuildWrap) ReplaceEnv ¶
func (c *CommandOnbuildWrap) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
func (*CommandOnbuildWrap) ShouldRun ¶
func (c *CommandOnbuildWrap) ShouldRun(b *Build) (bool, error)
ShouldRun returns true if the command should be executed
func (*CommandOnbuildWrap) String ¶
func (c *CommandOnbuildWrap) String() string
String returns the human readable string representation of the command
type CommandUser ¶
type CommandUser struct {
CommandBase
}
CommandUser implements USER
func (*CommandUser) Execute ¶
func (c *CommandUser) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandUser) ReplaceEnv ¶
func (c *CommandUser) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandVolume ¶
type CommandVolume struct {
CommandBase
}
CommandVolume implements VOLUME
func (*CommandVolume) Execute ¶
func (c *CommandVolume) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandVolume) ReplaceEnv ¶
func (c *CommandVolume) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type CommandWorkdir ¶
type CommandWorkdir struct {
CommandBase
}
CommandWorkdir implements WORKDIR
func (*CommandWorkdir) Execute ¶
func (c *CommandWorkdir) Execute(b *Build) (s State, err error)
Execute runs the command
func (*CommandWorkdir) ReplaceEnv ¶
func (c *CommandWorkdir) ReplaceEnv(env []string) error
ReplaceEnv implements EnvReplacableCommand interface
type Config ¶
type Config struct { OutStream io.Writer InStream io.ReadCloser ContextDir string ID string Dockerignore []string ArtifactsPath string Pull bool NoGarbage bool Attach bool Verbose bool NoCache bool ReloadCache bool Push bool CacheDir string LogJSON bool BuildArgs map[string]string }
Config used specify parameters for the builder in New()
type ConfigCommand ¶
type ConfigCommand struct {
// contains filtered or unexported fields
}
ConfigCommand configuration parameters for any command
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient implements the client that works with a docker socket
func NewDockerClient ¶
func NewDockerClient(options DockerClientOptions) *DockerClient
NewDockerClient makes a new client that works with a docker socket
func (*DockerClient) CommitContainer ¶
func (c *DockerClient) CommitContainer(s *State) (*docker.Image, error)
CommitContainer commits docker container
func (*DockerClient) CreateContainer ¶
func (c *DockerClient) CreateContainer(s State) (string, error)
CreateContainer creates docker container
func (*DockerClient) EnsureContainer ¶
func (c *DockerClient) EnsureContainer(containerName string, config *docker.Config, hostConfig *docker.HostConfig, purpose string) (containerID string, err error)
EnsureContainer checks if container with specified name exists and creates it otherwise
func (*DockerClient) EnsureImage ¶
func (c *DockerClient) EnsureImage(imageName string) (err error)
EnsureImage checks if the image exists and pulls if not
func (*DockerClient) InspectContainer ¶
func (c *DockerClient) InspectContainer(containerName string) (container *docker.Container, err error)
InspectContainer simply inspects the container by name or ID
func (*DockerClient) InspectImage ¶
func (c *DockerClient) InspectImage(name string) (img *docker.Image, err error)
InspectImage inspects docker image it does not give an error when image not found, but returns nil instead
func (*DockerClient) ListImageTags ¶
func (c *DockerClient) ListImageTags(name string) (images []*imagename.ImageName, err error)
ListImageTags returns the list of images instances obtained from all tags existing in the registry
func (*DockerClient) ListImages ¶
func (c *DockerClient) ListImages() (images []*imagename.ImageName, err error)
ListImages lists all pulled images in the local docker registry
func (*DockerClient) PullImage ¶
func (c *DockerClient) PullImage(name string) error
PullImage pulls docker image
func (*DockerClient) PushImage ¶
func (c *DockerClient) PushImage(imageName string) (digest string, err error)
PushImage pushes the image, does retries if configured
func (*DockerClient) RemoveContainer ¶
func (c *DockerClient) RemoveContainer(containerID string) error
RemoveContainer removes docker container
func (*DockerClient) RemoveImage ¶
func (c *DockerClient) RemoveImage(imageID string) error
RemoveImage removes docker image
func (*DockerClient) ResolveHostPath ¶
func (c *DockerClient) ResolveHostPath(path string) (resultPath string, err error)
ResolveHostPath proxy for the dockerclient.ResolveHostPath
func (*DockerClient) RunContainer ¶
func (c *DockerClient) RunContainer(containerID string, attachStdin bool) error
RunContainer runs docker container and optionally attaches stdin
func (*DockerClient) TagImage ¶
func (c *DockerClient) TagImage(imageID, imageName string) error
TagImage adds tag to the image
func (*DockerClient) UploadToContainer ¶
UploadToContainer uploads files to a docker container
type DockerClientOptions ¶
type DockerClientOptions struct { Client *docker.Client Auth *docker.AuthConfigurations Log *logrus.Logger S3storage *s3.StorageS3 StdoutContainerFormatter logrus.Formatter StderrContainerFormatter logrus.Formatter PushRetryCount int Host string LogExactSizes bool }
DockerClientOptions stores options are used to create DockerClient object
type EnvReplacableCommand ¶
EnvReplacableCommand interface describes the command that can replace ENV variables into arguments of itself
type Plan ¶
type Plan []Command
Plan is the list of commands to be executed sequentially by a build process
type Rockerfile ¶
type Rockerfile struct { Name string Source string Content string Vars template.Vars Funs template.Funs // contains filtered or unexported fields }
Rockerfile represents the data structure of a Rockerfile
func NewRockerfile ¶
func NewRockerfile(name string, in io.Reader, vars template.Vars, funs template.Funs) (r *Rockerfile, err error)
NewRockerfile reads parses Rockerfile from an io.Reader
func NewRockerfileFromFile ¶
func NewRockerfileFromFile(name string, vars template.Vars, funs template.Funs) (r *Rockerfile, err error)
NewRockerfileFromFile reads and parses Rockerfile from a file
func (*Rockerfile) Commands ¶
func (r *Rockerfile) Commands() []ConfigCommand
Commands returns the list of command configurations from the Rockerfile
type State ¶
type State struct { Config docker.Config ImageID string ParentID string ExportsID string NoBaseImage bool ProducedImage bool InjectCommands []string Commits []string ParentSize int64 Size int64 NoCache StateNoCache }
State is the build state TODO: document
func (*State) CleanCommits ¶
CleanCommits resets the commits struct
func (State) Equals ¶
Equals returns true if the two states are equal NOTE: we identify unique commands by commits, so state uniqueness is simply a commit
func (State) GetCommits ¶
GetCommits returns merged commits string
type StateNoCache ¶
type StateNoCache struct { Dockerignore []string CacheBusted bool CmdSet bool ContainerID string HostConfig docker.HostConfig BuildArgs map[string]string }
StateNoCache is a struct that cannot be overridden by a cached item
type URLFetcher ¶
type URLFetcher interface { Get(url string) (*URLInfo, error) GetInfo(url string) (*URLInfo, error) }
URLFetcher is an interface to fetch urls from internets
type URLFetcherFS ¶
type URLFetcherFS struct {
// contains filtered or unexported fields
}
URLFetcherFS is an URLFetcher backed by FS cache
func NewURLFetcherFS ¶
func NewURLFetcherFS(base string, noCache bool, httpClient *http.Client) (cache *URLFetcherFS)
NewURLFetcherFS returns an instance of URLFetcherFS, initialized to live in <base>/url_fetcher_cache