Skip to content

Commit

Permalink
Use the Compose name field if present
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Jul 24, 2024
1 parent 64313f6 commit d237416
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit d237416

Please sign in to comment.