diff --git a/cli/compose/loader/full-example.yml b/cli/compose/loader/full-example.yml index d193dccd31c9..0896c84309d9 100644 --- a/cli/compose/loader/full-example.yml +++ b/cli/compose/loader/full-example.yml @@ -2,6 +2,13 @@ version: "3.4" services: foo: + + build: + context: ./dir + dockerfile: Dockerfile-alternate + args: + foo: bar + cap_add: - ALL diff --git a/cli/compose/loader/loader_test.go b/cli/compose/loader/loader_test.go index 295e91e1e781..a2606ea2906b 100644 --- a/cli/compose/loader/loader_test.go +++ b/cli/compose/loader/loader_test.go @@ -686,6 +686,11 @@ func TestFullExample(t *testing.T) { expectedServiceConfig := types.ServiceConfig{ Name: "foo", + Build: types.BuildConfig{ + Context: "./dir", + Dockerfile: "Dockerfile-alternative", + Args: map[string]*string{"foo": strPtr("bar")}, + }, CapAdd: []string{"ALL"}, CapDrop: []string{"NET_ADMIN", "SYS_ADMIN"}, CgroupParent: "m-executor-abcd", diff --git a/cli/compose/types/types.go b/cli/compose/types/types.go index 8feaf4289daa..5b39e61fe30d 100644 --- a/cli/compose/types/types.go +++ b/cli/compose/types/types.go @@ -78,9 +78,10 @@ type Config struct { type ServiceConfig struct { Name string - CapAdd []string `mapstructure:"cap_add"` - CapDrop []string `mapstructure:"cap_drop"` - CgroupParent string `mapstructure:"cgroup_parent"` + Build BuildConfig `mapstructure:"build"` + CapAdd []string `mapstructure:"cap_add"` + CapDrop []string `mapstructure:"cap_drop"` + CgroupParent string `mapstructure:"cgroup_parent"` Command ShellCommand Configs []ServiceConfigObjConfig ContainerName string `mapstructure:"container_name"` @@ -125,6 +126,14 @@ type ServiceConfig struct { WorkingDir string `mapstructure:"working_dir"` } +// BuildConfig is a type for build +// using the same format at libcompose: https://github.com/docker/libcompose/blob/master/yaml/build.go#L12 +type BuildConfig struct { + Context string + Dockerfile string + Args map[string]*string +} + // ShellCommand is a string or list of string args type ShellCommand []string