From c43e157e221210f60e1af73ff71e551159630988 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Fri, 3 Mar 2023 10:33:44 +0100 Subject: [PATCH] introduce dockerfile_inline Signed-off-by: Nicolas De Loof --- loader/normalize.go | 2 +- loader/validate.go | 6 ++++++ schema/compose-spec.json | 1 + types/types.go | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/loader/normalize.go b/loader/normalize.go index 9153b56f..0c869f38 100644 --- a/loader/normalize.go +++ b/loader/normalize.go @@ -72,7 +72,7 @@ func Normalize(project *types.Project, resolvePaths bool) error { } if s.Build != nil { - if s.Build.Dockerfile == "" { + if s.Build.Dockerfile == "" && s.Build.DockerfileInline == "" { s.Build.Dockerfile = "Dockerfile" } localContext := absPath(project.WorkingDir, s.Build.Context) diff --git a/loader/validate.go b/loader/validate.go index a6a2c30a..6b1d6841 100644 --- a/loader/validate.go +++ b/loader/validate.go @@ -32,6 +32,12 @@ func checkConsistency(project *types.Project) error { return errors.Wrapf(errdefs.ErrInvalid, "service %q has neither an image nor a build context specified", s.Name) } + if s.Build != nil { + if s.Build.DockerfileInline != "" && s.Build.Dockerfile != "" { + return errors.Wrapf(errdefs.ErrInvalid, "service %q declares mutualy exclusive dockerfile and dockerfile_inline", s.Name) + } + } + for network := range s.Networks { if _, ok := project.Networks[network]; !ok { return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined network %s", s.Name, network)) diff --git a/schema/compose-spec.json b/schema/compose-spec.json index 78d6979f..921f1f34 100644 --- a/schema/compose-spec.json +++ b/schema/compose-spec.json @@ -91,6 +91,7 @@ "properties": { "context": {"type": "string"}, "dockerfile": {"type": "string"}, + "dockerfile_inline": {"type": "string"}, "args": {"$ref": "#/definitions/list_or_dict"}, "ssh": {"$ref": "#/definitions/list_or_dict"}, "labels": {"$ref": "#/definitions/list_or_dict"}, diff --git a/types/types.go b/types/types.go index f3363c5c..6fce1989 100644 --- a/types/types.go +++ b/types/types.go @@ -296,6 +296,7 @@ func (s set) toSlice() []string { type BuildConfig struct { Context string `yaml:",omitempty" json:"context,omitempty"` Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"` + DockerfileInline string `yaml:",omitempty" json:"dockerfile_inline,omitempty"` Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"` SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"` Labels Labels `yaml:",omitempty" json:"labels,omitempty"`