Skip to content

Commit 02f25ec

Browse files
authored
Merge pull request #354 from laurazard/add-build-context
Add `additional_contexts` to `build` service config
2 parents 37ba724 + a8185cd commit 02f25ec

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

loader/full-example.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ services:
1515
- foo
1616
- bar
1717
labels: [FOO=BAR]
18+
additional_contexts:
19+
foo: /bar
1820
secrets:
1921
- secret1
2022
- source: secret2

loader/full-struct_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
5050
Name: "foo",
5151

5252
Build: &types.BuildConfig{
53-
Context: "./dir",
54-
Dockerfile: "Dockerfile",
55-
Args: map[string]*string{"foo": strPtr("bar")},
56-
SSH: []types.SSHKey{{ID: "default", Path: ""}},
57-
Target: "foo",
58-
Network: "foo",
59-
CacheFrom: []string{"foo", "bar"},
60-
Labels: map[string]string{"FOO": "BAR"},
53+
Context: "./dir",
54+
Dockerfile: "Dockerfile",
55+
Args: map[string]*string{"foo": strPtr("bar")},
56+
SSH: []types.SSHKey{{ID: "default", Path: ""}},
57+
Target: "foo",
58+
Network: "foo",
59+
CacheFrom: []string{"foo", "bar"},
60+
AdditionalContexts: map[string]*string{"foo": strPtr("/bar")},
61+
Labels: map[string]string{"FOO": "BAR"},
6162
Secrets: []types.ServiceSecretConfig{
6263
{
6364
Source: "secret1",
@@ -597,6 +598,8 @@ services:
597598
cache_from:
598599
- foo
599600
- bar
601+
additional_contexts:
602+
foo: /bar
600603
network: foo
601604
target: foo
602605
secrets:
@@ -1137,6 +1140,9 @@ func fullExampleJSON(workingDir, homeDir string) string {
11371140
"foo",
11381141
"bar"
11391142
],
1143+
"additional_contexts": {
1144+
"foo": "/bar"
1145+
},
11401146
"network": "foo",
11411147
"target": "foo",
11421148
"secrets": [

schema/compose-spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"cache_from": {"type": "array", "items": {"type": "string"}},
9898
"cache_to": {"type": "array", "items": {"type": "string"}},
9999
"no_cache": {"type": "boolean"},
100+
"additional_contexts": {"$ref": "#/definitions/list_or_dict"},
100101
"network": {"type": "string"},
101102
"pull": {"type": "boolean"},
102103
"target": {"type": "string"},

types/types.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -294,23 +294,24 @@ func (s set) toSlice() []string {
294294

295295
// BuildConfig is a type for build
296296
type BuildConfig struct {
297-
Context string `yaml:",omitempty" json:"context,omitempty"`
298-
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
299-
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
300-
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
301-
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
302-
CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
303-
CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
304-
NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
305-
Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty"`
306-
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
307-
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
308-
Network string `yaml:",omitempty" json:"network,omitempty"`
309-
Target string `yaml:",omitempty" json:"target,omitempty"`
310-
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
311-
Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"`
312-
Platforms StringList `mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty"`
313-
Privileged bool `yaml:",omitempty" json:"privileged,omitempty"`
297+
Context string `yaml:",omitempty" json:"context,omitempty"`
298+
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
299+
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
300+
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
301+
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
302+
CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
303+
CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
304+
NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
305+
AdditionalContexts MappingWithEquals `mapstructure:"additional_contexts" yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty"`
306+
Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty"`
307+
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
308+
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
309+
Network string `yaml:",omitempty" json:"network,omitempty"`
310+
Target string `yaml:",omitempty" json:"target,omitempty"`
311+
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
312+
Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"`
313+
Platforms StringList `mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty"`
314+
Privileged bool `yaml:",omitempty" json:"privileged,omitempty"`
314315

315316
Extensions map[string]interface{} `yaml:",inline" json:"-"`
316317
}

0 commit comments

Comments
 (0)