diff --git a/bake/compose.go b/bake/compose.go index 780ca76a..db33a8c9 100644 --- a/bake/compose.go +++ b/bake/compose.go @@ -53,7 +53,8 @@ func ParseCompose(dt []byte) (*Config, error) { // TODO: add platforms } if s.Build.Target != "" { - t.Target = &s.Build.Target + target := s.Build.Target + t.Target = &target } if s.Image != "" { t.Tags = []string{s.Image} diff --git a/bake/compose_test.go b/bake/compose_test.go index d0f46b29..2f367179 100644 --- a/bake/compose_test.go +++ b/bake/compose_test.go @@ -39,3 +39,23 @@ services: require.Equal(t, 1, len(c.Target["webapp"].Args)) require.Equal(t, "123", c.Target["webapp"].Args["buildno"]) } + +func TestParseComposeTarget(t *testing.T) { + var dt = []byte(` +version: "3.7" + +services: + db: + build: + target: db + webapp: + build: + target: webapp +`) + + c, err := ParseCompose(dt) + require.NoError(t, err) + + require.Equal(t, "db", *c.Target["db"].Target) + require.Equal(t, "webapp", *c.Target["webapp"].Target) +}