Browse Source

build dependent service images when required

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 6 months ago
parent
commit
f4fc010d6b

+ 1 - 0
cmd/compose/up.go

@@ -261,6 +261,7 @@ func runUp(
 			return err
 		}
 		bo.Services = services
+		bo.Deps = !upOptions.noDeps
 		build = &bo
 	}
 

+ 12 - 0
pkg/e2e/build_test.go

@@ -524,3 +524,15 @@ func TestBuildEntitlements(t *testing.T) {
 		}
 	})
 }
+
+func TestBuildDependsOn(t *testing.T) {
+	c := NewParallelCLI(t)
+
+	t.Cleanup(func() {
+		c.RunDockerComposeCmd(t, "-f", "fixtures/build-dependencies/compose-depends_on.yaml", "down", "--rmi=local")
+	})
+
+	res := c.RunDockerComposeCmd(t, "-f", "fixtures/build-dependencies/compose-depends_on.yaml", "--progress=plain", "up", "test2")
+	out := res.Combined()
+	assert.Check(t, strings.Contains(out, "test1  Built"))
+}

+ 15 - 0
pkg/e2e/fixtures/build-dependencies/compose-depends_on.yaml

@@ -0,0 +1,15 @@
+services:
+  test1:
+    pull_policy: build
+    build:
+      dockerfile_inline: FROM alpine
+    command:
+      - echo
+      - "test 1 success"
+  test2:
+    image: alpine
+    depends_on:
+      - test1
+    command:
+      - echo
+      - "test 2 success"