From d237416fa179994de451bb01c98a03879cd3c772 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Wed, 24 Jul 2024 08:45:22 +0100 Subject: [PATCH] Use the Compose name field if present --- pkg/compose/compose.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/compose/compose.go b/pkg/compose/compose.go index 9f71daf1..75d5960c 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -44,16 +44,6 @@ func TargetTags(files []bake.File) (map[string][]string, error) { return nil, err } - var projectName string - path, err := filepath.Abs(files[0].Name) - if err != nil { - return nil, err - } - dir := filepath.Base(filepath.Dir(path)) - if dir != "." { - projectName = dir - } - details := compose.ConfigDetails{ ConfigFiles: configFiles, Environment: envs, @@ -67,6 +57,18 @@ func TargetTags(files []bake.File) (map[string][]string, error) { return nil, err } + projectName := cfg.Name + if projectName == "" { + path, err := filepath.Abs(files[0].Name) + if err != nil { + return nil, err + } + dir := filepath.Base(filepath.Dir(path)) + if dir != "." { + projectName = dir + } + } + targetTags := map[string][]string{} for _, srv := range cfg.Services { if srv.Build == nil {