grim/convey

Parents dc40ca1d93b5
Children eef6346adf05
Add support for building individual stages of a multi stage dockerfile
--- a/ChangeLog Wed Nov 15 11:33:59 2017 -0600
+++ b/ChangeLog Wed Nov 22 11:48:51 2017 -0600
@@ -2,6 +2,7 @@
* Changed TaskTimeout to PlanTimeout. Fixed # 134
* Added --list-environment to show the config and builtin environment variables. Fixed #132
* Added a user option to the Docker run task. PR #38 (Eric Fritz)
+ * Added a target option to the Docker build task. To specify which stage to use in a multi stage Dockerfile.
0.11.1: 20171021
* Fix a regression in the environment mapper that could mess up script attributes. PR #37 (Eric Fritz)
--- a/REFERENCE.md Wed Nov 15 11:33:59 2017 -0600
+++ b/REFERENCE.md Wed Nov 22 11:48:51 2017 -0600
@@ -220,6 +220,7 @@
| labels | | | A list of labels to set on the image being built |
| tag | | | The tag to apply to the image |
| tags | | | The list of tags as described above |
+| target | | | The name of the target to build in a multi stage dockerfile |
At least one tag must be supplied by either the `tag` or `tags` attribute. If both are
supplied, `tag` is inserted to the front of `tags`.
--- a/docker/build.go Wed Nov 15 11:33:59 2017 -0600
+++ b/docker/build.go Wed Nov 22 11:48:51 2017 -0600
@@ -35,6 +35,7 @@
Files yaml.StringOrSlice `yaml:"files"`
Tag string `yaml:"tag"`
Tags yaml.StringOrSlice `yaml:"tags"`
+ Target string `yaml:"target"`
Labels yaml.StringOrSlice `yaml:"labels"`
Arguments yaml.StringOrSlice `yaml:"arguments"`
}
@@ -44,6 +45,7 @@
{{range .Tags}} -t {{.}}{{end}}
{{range .Labels}} --label '{{.}}'{{end}}
{{range .Arguments}} --build-arg {{.}}{{end}}
+{{if .Target}} --target {{.Target}}{{end}}
{{.buildContext}}`
func (b *Build) Execute(name string, logger *gomol.LogAdapter, env []string, st *state.State) error {
@@ -112,6 +114,7 @@
"dockerfile": filepath.Join(tmpDir, filepath.Base(dockerfile)),
"buildContext": tmpDir,
"Tags": tags,
+ "Target": b.Target,
"Labels": labels,
"Arguments": arguments,
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/multi-stage/Dockerfile Wed Nov 22 11:48:51 2017 -0600
@@ -0,0 +1,13 @@
+# define our base
+FROM alpine:edge as multi-stage-base
+
+# create our first child
+FROM multi-stage-base as multi-stage-left
+
+CMD ["echo", "left"]
+
+# create our second child
+FROM multi-stage-base as multi-stage-right
+
+CMD ["echo", "right"]
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/multi-stage/convey.yml Wed Nov 22 11:48:51 2017 -0600
@@ -0,0 +1,41 @@
+tasks:
+ import:
+ type: import
+ files: .
+ build-left:
+ type: build
+ dockerfile: Dockerfile
+ target: multi-stage-left
+ tags: multi-stage-left
+ build-right:
+ type: build
+ dockerfile: Dockerfile
+ target: multi-stage-right
+ tags: multi-stage-right
+ run-left:
+ image: multi-stage-left
+ run-right:
+ image: multi-stage-right
+ cleanup:
+ type: remove
+ images:
+ - multi-stage-left
+ - multi-stage-right
+plans:
+ default:
+ stages:
+ - name: import
+ tasks: import
+ - name: build
+ tasks:
+ - build-left
+ - build-right
+ concurrent: true
+ - name: test
+ tasks:
+ - run-left
+ - run-right
+ concurrent: true
+ - name: cleanup
+ tasks: cleanup
+