bake: support inline dockerfile

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
pull/398/head
Tonis Tiigi 4 years ago
parent cffcd57edb
commit 570e733a51

@ -373,20 +373,21 @@ type Target struct {
// Inherits is the only field that cannot be overridden with --set // Inherits is the only field that cannot be overridden with --set
Inherits []string `json:"inherits,omitempty" hcl:"inherits,optional"` Inherits []string `json:"inherits,omitempty" hcl:"inherits,optional"`
Context *string `json:"context,omitempty" hcl:"context,optional"` Context *string `json:"context,omitempty" hcl:"context,optional"`
Dockerfile *string `json:"dockerfile,omitempty" hcl:"dockerfile,optional"` Dockerfile *string `json:"dockerfile,omitempty" hcl:"dockerfile,optional"`
Args map[string]string `json:"args,omitempty" hcl:"args,optional"` DockerfileInline *string `json:"dockerfile-inline,omitempty" hcl:"dockerfile-inline,optional"`
Labels map[string]string `json:"labels,omitempty" hcl:"labels,optional"` Args map[string]string `json:"args,omitempty" hcl:"args,optional"`
Tags []string `json:"tags,omitempty" hcl:"tags,optional"` Labels map[string]string `json:"labels,omitempty" hcl:"labels,optional"`
CacheFrom []string `json:"cache-from,omitempty" hcl:"cache-from,optional"` Tags []string `json:"tags,omitempty" hcl:"tags,optional"`
CacheTo []string `json:"cache-to,omitempty" hcl:"cache-to,optional"` CacheFrom []string `json:"cache-from,omitempty" hcl:"cache-from,optional"`
Target *string `json:"target,omitempty" hcl:"target,optional"` CacheTo []string `json:"cache-to,omitempty" hcl:"cache-to,optional"`
Secrets []string `json:"secret,omitempty" hcl:"secret,optional"` Target *string `json:"target,omitempty" hcl:"target,optional"`
SSH []string `json:"ssh,omitempty" hcl:"ssh,optional"` Secrets []string `json:"secret,omitempty" hcl:"secret,optional"`
Platforms []string `json:"platforms,omitempty" hcl:"platforms,optional"` SSH []string `json:"ssh,omitempty" hcl:"ssh,optional"`
Outputs []string `json:"output,omitempty" hcl:"output,optional"` Platforms []string `json:"platforms,omitempty" hcl:"platforms,optional"`
Pull *bool `json:"pull,omitempty" hcl:"pull,optional"` Outputs []string `json:"output,omitempty" hcl:"output,optional"`
NoCache *bool `json:"no-cache,omitempty" hcl:"no-cache,optional"` Pull *bool `json:"pull,omitempty" hcl:"pull,optional"`
NoCache *bool `json:"no-cache,omitempty" hcl:"no-cache,optional"`
// IMPORTANT: if you add more fields here, do not forget to update newOverrides and README. // IMPORTANT: if you add more fields here, do not forget to update newOverrides and README.
} }
@ -460,6 +461,9 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
ContextPath: contextPath, ContextPath: contextPath,
DockerfilePath: dockerfilePath, DockerfilePath: dockerfilePath,
} }
if t.DockerfileInline != nil {
bi.DockerfileInline = *t.DockerfileInline
}
updateContext(&bi, inp) updateContext(&bi, inp)
bo := &build.Options{ bo := &build.Options{
@ -527,6 +531,9 @@ func merge(t1, t2 *Target) *Target {
if t2.Dockerfile != nil { if t2.Dockerfile != nil {
t1.Dockerfile = t2.Dockerfile t1.Dockerfile = t2.Dockerfile
} }
if t2.DockerfileInline != nil {
t1.DockerfileInline = t2.DockerfileInline
}
for k, v := range t2.Args { for k, v := range t2.Args {
if t1.Args == nil { if t1.Args == nil {
t1.Args = map[string]string{} t1.Args = map[string]string{}

@ -62,10 +62,11 @@ type Options struct {
} }
type Inputs struct { type Inputs struct {
ContextPath string ContextPath string
DockerfilePath string DockerfilePath string
InStream io.Reader InStream io.Reader
ContextState *llb.State ContextState *llb.State
DockerfileInline string
} }
type DriverInfo struct { type DriverInfo struct {
@ -780,6 +781,10 @@ func LoadInputs(ctx context.Context, d driver.Driver, inp Inputs, pw progress.Wr
return nil, errors.Errorf("unable to prepare context: path %q not found", inp.ContextPath) return nil, errors.Errorf("unable to prepare context: path %q not found", inp.ContextPath)
} }
if inp.DockerfileInline != "" {
dockerfileReader = strings.NewReader(inp.DockerfileInline)
}
if dockerfileReader != nil { if dockerfileReader != nil {
dockerfileDir, err = createTempDockerfile(dockerfileReader) dockerfileDir, err = createTempDockerfile(dockerfileReader)
if err != nil { if err != nil {

Loading…
Cancel
Save