Browse Source

Merge pull request #1001 from gtardif/compose_build_img_name

If compose file has a build section and no image name, build image with the right derived image tag
Guillaume Tardif 5 years ago
parent
commit
91083bc42c
1 changed files with 5 additions and 1 deletions
  1. 5 1
      local/build.go

+ 5 - 1
local/build.go

@@ -52,7 +52,11 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
 			}
 		}
 		if service.Build != nil {
-			opts[service.Name] = s.toBuildOptions(service, project.WorkingDir)
+			imageName := service.Image
+			if imageName == "" {
+				imageName = project.Name + "_" + service.Name
+			}
+			opts[imageName] = s.toBuildOptions(service, project.WorkingDir)
 			continue
 		}