Skip to content

Commit

Permalink
Merge pull request #354 from laurazard/add-build-context
Browse files Browse the repository at this point in the history
Add `additional_contexts` to `build` service config
  • Loading branch information
glours authored Mar 13, 2023
2 parents 37ba724 + a8185cd commit 02f25ec
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
2 changes: 2 additions & 0 deletions loader/full-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ services:
- foo
- bar
labels: [FOO=BAR]
additional_contexts:
foo: /bar
secrets:
- secret1
- source: secret2
Expand Down
22 changes: 14 additions & 8 deletions loader/full-struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
Name: "foo",

Build: &types.BuildConfig{
Context: "./dir",
Dockerfile: "Dockerfile",
Args: map[string]*string{"foo": strPtr("bar")},
SSH: []types.SSHKey{{ID: "default", Path: ""}},
Target: "foo",
Network: "foo",
CacheFrom: []string{"foo", "bar"},
Labels: map[string]string{"FOO": "BAR"},
Context: "./dir",
Dockerfile: "Dockerfile",
Args: map[string]*string{"foo": strPtr("bar")},
SSH: []types.SSHKey{{ID: "default", Path: ""}},
Target: "foo",
Network: "foo",
CacheFrom: []string{"foo", "bar"},
AdditionalContexts: map[string]*string{"foo": strPtr("/bar")},
Labels: map[string]string{"FOO": "BAR"},
Secrets: []types.ServiceSecretConfig{
{
Source: "secret1",
Expand Down Expand Up @@ -597,6 +598,8 @@ services:
cache_from:
- foo
- bar
additional_contexts:
foo: /bar
network: foo
target: foo
secrets:
Expand Down Expand Up @@ -1137,6 +1140,9 @@ func fullExampleJSON(workingDir, homeDir string) string {
"foo",
"bar"
],
"additional_contexts": {
"foo": "/bar"
},
"network": "foo",
"target": "foo",
"secrets": [
Expand Down
1 change: 1 addition & 0 deletions schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"cache_from": {"type": "array", "items": {"type": "string"}},
"cache_to": {"type": "array", "items": {"type": "string"}},
"no_cache": {"type": "boolean"},
"additional_contexts": {"$ref": "#/definitions/list_or_dict"},
"network": {"type": "string"},
"pull": {"type": "boolean"},
"target": {"type": "string"},
Expand Down
35 changes: 18 additions & 17 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,24 @@ func (s set) toSlice() []string {

// BuildConfig is a type for build
type BuildConfig struct {
Context string `yaml:",omitempty" json:"context,omitempty"`
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty"`
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Target string `yaml:",omitempty" json:"target,omitempty"`
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"`
Platforms StringList `mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty"`
Privileged bool `yaml:",omitempty" json:"privileged,omitempty"`
Context string `yaml:",omitempty" json:"context,omitempty"`
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
AdditionalContexts MappingWithEquals `mapstructure:"additional_contexts" yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty"`
Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty"`
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Target string `yaml:",omitempty" json:"target,omitempty"`
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"`
Platforms StringList `mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty"`
Privileged bool `yaml:",omitempty" json:"privileged,omitempty"`

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

0 comments on commit 02f25ec

Please sign in to comment.