summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorDan Duvall <dduvall@wikimedia.org>2017-08-30 09:47:41 -0700
committerDan Duvall <dduvall@wikimedia.org>2017-09-07 10:01:34 -0700
commit410085e1f5be759b6a2bfbe08a51dca84aa18e3c (patch)
tree9c0b1e24953082cfe96e84b0924ba0ac90c67100 /build
parent2a19f04679b042567dd7ed9c0208eacbb63b8d26 (diff)
downloadblubber-410085e1f5be759b6a2bfbe08a51dca84aa18e3c.tar.gz
Support `copies` config entry for multi-stage builds
Summary: Support a `copies` variant config entry that will result in a multi-stage build, copying both shared library files and application directory from a previously defined variant. This is essentially a shorthand for two `artifacts` entries that are likely to be idiomatic to multi-stage build/prod configurations. Defined a new abstract `build.CopyFrom` instruction and corresponding `docker.DockerCopyFrom` instruction and refactored the writing of these Dockerfile lines to be accomplished using an `InstructionsForPhase` method on `config.ArtifactsConfig`. Implemented new support for `copies` configuration in `config.VariantConfig` and an `InstructionsForPhase` method that returns `build.CopyFrom` instructions for both the shared library and application directories. Fixes T174622 Depends on D759 Test Plan: Run `go test ./...`. Run `blubber blubber.example.yaml production` and ensure the right `COPY --from` lines are included for the final stage. Reviewers: thcipriani, mobrovac, hashar, mmodell, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Maniphest Tasks: T174622 Differential Revision: https://phabricator.wikimedia.org/D768
Diffstat (limited to 'build')
-rw-r--r--build/instructions.go9
-rw-r--r--build/instructions_test.go6
2 files changed, 15 insertions, 0 deletions
diff --git a/build/instructions.go b/build/instructions.go
index 5c12796..1b954a2 100644
--- a/build/instructions.go
+++ b/build/instructions.go
@@ -50,6 +50,15 @@ func (copy Copy) Compile() []string {
return append(quoteAll(copy.Sources), quote(copy.Destination))
}
+type CopyFrom struct {
+ From string
+ Copy
+}
+
+func (cf CopyFrom) Compile() []string {
+ return append([]string{cf.From}, cf.Copy.Compile()...)
+}
+
type Env struct {
Definitions map[string]string
}
diff --git a/build/instructions_test.go b/build/instructions_test.go
index dbab4b5..8f9470c 100644
--- a/build/instructions_test.go
+++ b/build/instructions_test.go
@@ -36,6 +36,12 @@ func TestCopy(t *testing.T) {
assert.Equal(t, []string{`"source1"`, `"source2"`, `"dest"`}, i.Compile())
}
+func TestCopyFrom(t *testing.T) {
+ i := build.CopyFrom{"foo", build.Copy{[]string{"source1", "source2"}, "dest"}}
+
+ assert.Equal(t, []string{"foo", `"source1"`, `"source2"`, `"dest"`}, i.Compile())
+}
+
func TestEnv(t *testing.T) {
i := build.Env{map[string]string{
"fooname": "foovalue",