build dependent service images when required

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2025-06-02 11:45:48 +02:00 committed by Guillaume Lours
parent 693b9ef078
commit f4fc010d6b
3 changed files with 28 additions and 0 deletions

View File

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

View File

@ -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"))
}

View File

@ -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"