Skip to content

Commit

Permalink
Merge pull request #293 from depot/compose-name
Browse files Browse the repository at this point in the history
Use the Compose name field if present
  • Loading branch information
jacobwgillespie authored Jul 24, 2024
2 parents 64313f6 + d237416 commit df2c6a6
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 df2c6a6

Please sign in to comment.