Documentation ¶
Index ¶
- func HasStage(s []Stage, name string) (int, bool)
- func IsCurrentStage(s []Stage, name string) bool
- func Parse(ast *parser.Node) (stages []Stage, metaArgs []ArgCommand, err error)
- func ParseInstruction(node *parser.Node) (v interface{}, err error)
- type AddCommand
- type ArgCommand
- type BFlags
- type CmdCommand
- type Command
- type CopyCommand
- type EntrypointCommand
- type EnvCommand
- type ExposeCommand
- type Flag
- type FlagType
- type HealthCheckCommand
- type KeyValuePair
- type KeyValuePairOptional
- type KeyValuePairs
- type LabelCommand
- type MaintainerCommand
- type Mount
- type MountType
- type NetworkMode
- type OnbuildCommand
- type PlatformSpecific
- type RunCommand
- type ShareMode
- type ShellCommand
- type ShellDependantCmdLine
- type ShellInlineFile
- type SingleWordExpander
- type SourceContent
- type SourcesAndDest
- type Stage
- type StopSignalCommand
- type SupportsSingleWordExpansion
- type SupportsSingleWordExpansionRaw
- type UnknownInstructionError
- type UserCommand
- type VolumeCommand
- type WorkdirCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCurrentStage ¶
IsCurrentStage returns true if the provided stage name is the name of the current stage, and false otherwise.
func Parse ¶
func Parse(ast *parser.Node) (stages []Stage, metaArgs []ArgCommand, err error)
Parse a Dockerfile into a collection of buildable stages. metaArgs is a collection of ARG instructions that occur before the first FROM.
func ParseInstruction ¶
ParseInstruction converts an AST to a typed instruction (either a command or a build stage beginning when encountering a `FROM` statement)
Types ¶
type AddCommand ¶
type AddCommand struct { SourcesAndDest Chown string Chmod string Link bool KeepGitDir bool // whether to keep .git dir, only meaningful for git sources Checksum string // contains filtered or unexported fields }
AddCommand adds files from the provided sources to the target destination.
ADD foo /path
ADD supports tarball and remote URL handling, which may not always be desired - if you do not wish to have this automatic handling, use COPY.
func (*AddCommand) Expand ¶
func (c *AddCommand) Expand(expander SingleWordExpander) error
type ArgCommand ¶
type ArgCommand struct { Args []KeyValuePairOptional // contains filtered or unexported fields }
ArgCommand adds the specified variable to the list of variables that can be passed to the builder using the --build-arg flag for expansion and substitution.
ARG name[=value]
func (*ArgCommand) Expand ¶
func (c *ArgCommand) Expand(expander SingleWordExpander) error
type BFlags ¶
type BFlags struct { Args []string // actual flags/args from cmd line Err error // contains filtered or unexported fields }
BFlags contains all flags information for the builder
func NewBFlagsWithArgs ¶
NewBFlagsWithArgs returns the new BFlags struct with Args set to args
func (*BFlags) AddBool ¶
AddBool adds a bool flag to BFlags Note, any error will be generated when Parse() is called (see Parse).
func (*BFlags) AddString ¶
AddString adds a string flag to BFlags Note, any error will be generated when Parse() is called (see Parse).
func (*BFlags) AddStrings ¶
AddStrings adds a string flag to BFlags that can match multiple values
func (*BFlags) Parse ¶
Parse parses and checks if the BFlags is valid. Any error noticed during the AddXXX() funcs will be generated/returned here. We do this because an error during AddXXX() is more like a compile time error so it doesn't matter too much when we stop our processing as long as we do stop it, so this allows the code around AddXXX() to be just:
defFlag := AddString("description", "")
w/o needing to add an if-statement around each one.
type CmdCommand ¶
type CmdCommand struct { ShellDependantCmdLine // contains filtered or unexported fields }
CmdCommand sets the default command to run in the container on start.
CMD "echo hi" # sh -c "echo hi"
or
CMD ["echo", "hi"] # echo hi
type Command ¶
Command interface is implemented by every possible command in a Dockerfile.
The interface only exposes the minimal common elements shared between every command, while more detailed information per-command can be extracted using runtime type analysis, e.g. type-switches.
type CopyCommand ¶
type CopyCommand struct { SourcesAndDest From string Chown string Chmod string Link bool Parents bool // parents preserves directory structure // contains filtered or unexported fields }
CopyCommand copies files from the provided sources to the target destination.
COPY foo /path
Same as 'ADD' but without the magic additional tarball and remote URL handling.
func (*CopyCommand) Expand ¶
func (c *CopyCommand) Expand(expander SingleWordExpander) error
type EntrypointCommand ¶
type EntrypointCommand struct { ShellDependantCmdLine // contains filtered or unexported fields }
EntrypointCommand sets the default entrypoint of the container to use the provided command.
ENTRYPOINT /usr/sbin/nginx
Entrypoint uses the default shell if not in JSON format.
type EnvCommand ¶
type EnvCommand struct { Env KeyValuePairs // contains filtered or unexported fields }
EnvCommand allows setting an variable in the container's environment.
ENV key1 value1 [keyN valueN...]
func (*EnvCommand) Expand ¶
func (c *EnvCommand) Expand(expander SingleWordExpander) error
type ExposeCommand ¶
type ExposeCommand struct { Ports []string // contains filtered or unexported fields }
ExposeCommand marks a container port that can be exposed at runtime.
EXPOSE 6667/tcp 7000/tcp
type HealthCheckCommand ¶
type HealthCheckCommand struct { Health *container.HealthConfig // contains filtered or unexported fields }
HealthCheckCommand sets the default healthcheck command to run in the container.
HEALTHCHECK <health-config>
type KeyValuePair ¶
KeyValuePair represents an arbitrary named value.
This is useful for commands containing key-value maps that want to preserve the order of insertion, instead of map[string]string which does not.
func (*KeyValuePair) String ¶
func (kvp *KeyValuePair) String() string
type KeyValuePairOptional ¶
KeyValuePairOptional is identical to KeyValuePair, but allows for optional values.
func (*KeyValuePairOptional) String ¶
func (kvpo *KeyValuePairOptional) String() string
func (*KeyValuePairOptional) ValueString ¶
func (kvpo *KeyValuePairOptional) ValueString() string
type LabelCommand ¶
type LabelCommand struct { Labels KeyValuePairs // contains filtered or unexported fields }
LabelCommand sets an image label in the output
LABEL some json data describing the image
func NewLabelCommand ¶
func NewLabelCommand(k string, v string, NoExp bool) *LabelCommand
NewLabelCommand creates a new 'LABEL' command
func (*LabelCommand) Expand ¶
func (c *LabelCommand) Expand(expander SingleWordExpander) error
type MaintainerCommand ¶
type MaintainerCommand struct { Maintainer string // contains filtered or unexported fields }
MaintainerCommand (deprecated) allows specifying a maintainer details for the image.
MAINTAINER maintainer_name
type Mount ¶
type Mount struct { Type MountType From string Source string Target string ReadOnly bool SizeLimit int64 CacheID string CacheSharing ShareMode Required bool Mode *uint64 UID *uint64 GID *uint64 }
func GetMounts ¶
func GetMounts(cmd *RunCommand) []*Mount
type NetworkMode ¶
type NetworkMode = string
const ( NetworkDefault NetworkMode = "default" NetworkNone NetworkMode = "none" NetworkHost NetworkMode = "host" )
func GetNetwork ¶
func GetNetwork(cmd *RunCommand) NetworkMode
type OnbuildCommand ¶
type OnbuildCommand struct { Expression string // contains filtered or unexported fields }
OnbuildCommand allows specifying a command to be run on builds the use the resulting build image as a base image.
ONBUILD <some other command>
type PlatformSpecific ¶
PlatformSpecific adds platform checks to a command
type RunCommand ¶
type RunCommand struct { ShellDependantCmdLine FlagsUsed []string // contains filtered or unexported fields }
RunCommand runs a command.
RUN "echo hi" # sh -c "echo hi"
or
RUN ["echo", "hi"] # echo hi
func (*RunCommand) Expand ¶
func (c *RunCommand) Expand(expander SingleWordExpander) error
type ShellCommand ¶
ShellCommand sets a custom shell to use.
SHELL bash -e -c
type ShellDependantCmdLine ¶
type ShellDependantCmdLine struct { CmdLine strslice.StrSlice Files []ShellInlineFile PrependShell bool }
ShellDependantCmdLine represents a cmdline optionally prepended with the shell
type ShellInlineFile ¶
ShellInlineFile represents an inline file created for a shell command
type SingleWordExpander ¶
SingleWordExpander is a provider for variable expansion where a single word corresponds to a single output.
type SourceContent ¶
type SourceContent struct { Path string // path to the file Data string // string content from the file Expand bool // whether to expand file contents }
SourceContent represents an anonymous file object
type SourcesAndDest ¶
type SourcesAndDest struct { DestPath string // destination to write output SourcePaths []string // file path sources SourceContents []SourceContent // anonymous file sources }
SourcesAndDest represent a collection of sources and a destination
func (*SourcesAndDest) Expand ¶
func (s *SourcesAndDest) Expand(expander SingleWordExpander) error
func (*SourcesAndDest) ExpandRaw ¶
func (s *SourcesAndDest) ExpandRaw(expander SingleWordExpander) error
type Stage ¶
type Stage struct { Name string // name of the stage Commands []Command // commands contained within the stage BaseName string // name of the base stage or source Platform string // platform of base source to use Comment string // doc-comment directly above the stage SourceCode string // contents of the defining FROM command Location []parser.Range // location of the defining FROM command }
Stage represents a bundled collection of commands.
Each stage begins with a FROM command (which is consumed into the Stage), indicating the source or stage to derive from, and ends either at the end-of-the file, or the start of the next stage.
Stages can be named, and can be additionally configured to use a specific platform, in the case of a multi-arch base image.
func CurrentStage ¶
CurrentStage returns the last stage from a list of stages.
func (*Stage) AddCommand ¶
AddCommand appends a command to the stage.
type StopSignalCommand ¶
type StopSignalCommand struct { Signal string // contains filtered or unexported fields }
StopSignalCommand sets the signal that will be used to kill the container.
STOPSIGNAL signal
func (*StopSignalCommand) CheckPlatform ¶
func (c *StopSignalCommand) CheckPlatform(platform string) error
CheckPlatform checks that the command is supported in the target platform
func (*StopSignalCommand) Expand ¶
func (c *StopSignalCommand) Expand(expander SingleWordExpander) error
type SupportsSingleWordExpansion ¶
type SupportsSingleWordExpansion interface {
Expand(expander SingleWordExpander) error
}
SupportsSingleWordExpansion interface allows a command to support variable.
type SupportsSingleWordExpansionRaw ¶
type SupportsSingleWordExpansionRaw interface {
ExpandRaw(expander SingleWordExpander) error
}
SupportsSingleWordExpansionRaw interface allows a command to support variable expansion, while ensuring that minimal transformations are applied during expansion, so that quotes and other special characters are preserved.
type UnknownInstructionError ¶
UnknownInstructionError represents an error occurring when a command is unresolvable
func (*UnknownInstructionError) Error ¶
func (e *UnknownInstructionError) Error() string
type UserCommand ¶
type UserCommand struct { User string // contains filtered or unexported fields }
UserCommand sets the user for the rest of the stage, and when starting the container at run-time.
USER user
func (*UserCommand) Expand ¶
func (c *UserCommand) Expand(expander SingleWordExpander) error
type VolumeCommand ¶
type VolumeCommand struct { Volumes []string // contains filtered or unexported fields }
VolumeCommand exposes the specified volume for use in the build environment.
VOLUME /foo
func (*VolumeCommand) Expand ¶
func (c *VolumeCommand) Expand(expander SingleWordExpander) error
type WorkdirCommand ¶
type WorkdirCommand struct { Path string // contains filtered or unexported fields }
WorkdirCommand sets the current working directory for all future commands in the stage
WORKDIR /tmp
func (*WorkdirCommand) Expand ¶
func (c *WorkdirCommand) Expand(expander SingleWordExpander) error