Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'build' to types.go #481

Merged
merged 1 commit into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cli/compose/loader/full-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ version: "3.4"

services:
foo:

build:
context: ./dir
dockerfile: Dockerfile
args:
foo: bar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the other fields (target, network, cache_from, labels) to this as well.

target: foo
network: foo
cache_from:
- foo
- bar
labels: [FOO=BAR]



cap_add:
- ALL

Expand Down
15 changes: 13 additions & 2 deletions cli/compose/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,14 @@ version: "3"
services:
web:
image: web
build: ./web
build:
context: ./web
links:
- bar
db:
image: db
build: ./db
build:
context: ./db
`))
assert.NoError(t, err)

Expand Down Expand Up @@ -686,6 +688,15 @@ func TestFullExample(t *testing.T) {
expectedServiceConfig := types.ServiceConfig{
Name: "foo",

Build: types.BuildConfig{
Context: "./dir",
Dockerfile: "Dockerfile",
Args: map[string]*string{"foo": strPtr("bar")},
Target: "foo",
Network: "foo",
CacheFrom: []string{"foo", "bar"},
Labels: map[string]string{"FOO": "BAR"},
},
CapAdd: []string{"ALL"},
CapDrop: []string{"NET_ADMIN", "SYS_ADMIN"},
CgroupParent: "m-executor-abcd",
Expand Down
13 changes: 13 additions & 0 deletions cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type Config struct {
type ServiceConfig struct {
Name string

Build BuildConfig
CapAdd []string `mapstructure:"cap_add"`
CapDrop []string `mapstructure:"cap_drop"`
CgroupParent string `mapstructure:"cgroup_parent"`
Expand Down Expand Up @@ -125,6 +126,18 @@ 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 MappingWithEquals
Labels Labels
CacheFrom StringList `mapstructure:"cache_from"`
Network string
Target string
}

// ShellCommand is a string or list of string args
type ShellCommand []string

Expand Down