Documentation ¶
Overview ¶
Package dockerfilegenerator is a Dockerfile generation library. It receives any kind of Dockerfile instructions and spits out a generated Dockerfile.
Index ¶
- Constants
- type Arg
- type Cmd
- type CopyCommand
- type DockerfileData
- type DockerfileDataYaml
- type DockerfileTemplate
- type Entrypoint
- type EnvVariable
- type From
- type HealthCheck
- type Instruction
- type Label
- type Onbuild
- type Params
- type RunCommand
- type RunForm
- type Shell
- type Stage
- type User
- type Volume
- type Workdir
Constants ¶
const ( // ExecForm is essentially a json array of string, e.g. ["echo", "1"] ExecForm RunForm = "ExecForm" // ShellForm is the form of a usual terminal command, e.g. echo 1 ShellForm RunForm = "ShellForm" // RunCommandDefaultRunForm is the default RunForm for RunCommand RunCommandDefaultRunForm = ShellForm // CmdDefaultRunForm is the default RunForm for Cmd CmdDefaultRunForm = ExecForm // EntrypointDefaultRunForm is the default RunForm for Entrypoint EntrypointDefaultRunForm = ExecForm )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct { Name string `yaml:"name"` Value string `yaml:"value"` Test bool `yaml:"test,omitempty"` EnvVariable bool `yaml:"envVariable,omitempty"` }
Arg represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#arg
type Cmd ¶
Cmd represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#cmd
type CopyCommand ¶
type CopyCommand struct { Sources []string `yaml:"sources"` Destination string `yaml:"destination"` Chown string `yaml:"chown"` From string `yaml:"from"` }
CopyCommand represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#copy
func (CopyCommand) Render ¶
func (c CopyCommand) Render() string
Render returns a string in the form of COPY [--chown=<user>:<group>] <src>... <dest>
type DockerfileData ¶
type DockerfileData struct {
Stages []Stage `yaml:"stages,omitempty"`
}
DockerfileData struct can hold multiple stages for a multi-staged Dockerfile Check https://docs.docker.com/develop/develop-images/multistage-build/ for more information
func NewDockerFileDataFromYamlField ¶ added in v1.0.0
func NewDockerFileDataFromYamlField(filename, targetField string) (*DockerfileData, error)
NewDockerFileDataFromYamlField reads a YAML file and tries to extract Dockerfile data from the specified targetField option, examples: --target-field ".dev.dockerfileConfig" --target-field ".serverConfigs[0].docker.server"
func NewDockerFileDataFromYamlFile ¶
func NewDockerFileDataFromYamlFile(filename string) (*DockerfileData, error)
NewDockerFileDataFromYamlFile reads a file and return a *DockerfileData
type DockerfileDataYaml ¶
DockerfileDataYaml is used to decode yaml data. It has a Stages map instead of a slice for that purpose.
type DockerfileTemplate ¶
type DockerfileTemplate struct {
Data *DockerfileData
}
DockerfileTemplate defines the template struct that generates Dockerfile output
func NewDockerfileTemplate ¶
func NewDockerfileTemplate(data *DockerfileData) *DockerfileTemplate
NewDockerfileTemplate return a new NewDockerfileTemplate instance
type Entrypoint ¶
Entrypoint represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#entrypoint
func (Entrypoint) Render ¶
func (e Entrypoint) Render() string
Render returns a string in the form of ENTRYPOINT ["executable", "param1", "param2"]
type EnvVariable ¶
EnvVariable represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#env
func (EnvVariable) Render ¶
func (e EnvVariable) Render() string
Render returns a string in the form of ENV <key> <value>
type From ¶
From represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#from
type HealthCheck ¶
type HealthCheck struct {
Params `yaml:"params"`
}
HealthCheck represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#healthcheck
func (HealthCheck) Render ¶
func (h HealthCheck) Render() string
Render returns a string in the form of HEALTHCHECK [OPTIONS] CMD command
type Instruction ¶
type Instruction interface {
Render() string
}
Instruction represents a Dockerfile instruction, e.g. FROM alpine:latest
type Label ¶
Label represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#from
type Onbuild ¶
type Onbuild struct {
Params `yaml:"params"`
}
Onbuild represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#onbuuild
type Params ¶
type Params []string
Params is struct that supports rendering exec and shell form string
type RunCommand ¶
RunCommand represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#run
func (RunCommand) Render ¶
func (r RunCommand) Render() string
Render returns a string in the form of RUN <command>
type RunForm ¶
type RunForm string
RunForm specifies in which form the instruction string should be constructed. Check Dockerfile exec and shell forms for more information
type Shell ¶
type Shell struct {
Params `yaml:"params"`
}
Shell represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#shell
type Stage ¶
type Stage []Instruction
Stage is a set of instructions, the purpose is to keep the order of the given instructions and generate a Dockerfile using the output of these instructions
func (*Stage) UnmarshalYAML ¶
UnmarshalYAML implements an interface to let go-yaml be able to decode Stages in to Stage struct
type User ¶
User represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#user
type Volume ¶
Volume represents a Dockerfile instruction, see https://docs.docker.com/engine/reference/builder/#volume