@@ -141,10 +141,11 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
141141 Targets : map [string ]bakeTarget {},
142142 }
143143 var (
144- group bakeGroup
145- privileged bool
146- read []string
147- targets = make (map [string ]string , len (serviceToBeBuild )) // service name -> build target
144+ group bakeGroup
145+ privileged bool
146+ read []string
147+ expectedImages = make (map [string ]string , len (serviceToBeBuild )) // service name -> expected image
148+ targets = make (map [string ]string , len (serviceToBeBuild )) // service name -> build target
148149 )
149150
150151 // produce a unique ID for service used as bake target
@@ -203,6 +204,9 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
203204 }
204205 }
205206
207+ image := api .GetImageNameOrDefault (service , project .Name )
208+ expectedImages [serviceName ] = image
209+
206210 target := targets [serviceName ]
207211 cfg .Targets [target ] = bakeTarget {
208212 Context : build .Context ,
@@ -211,7 +215,7 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
211215 DockerfileInline : strings .ReplaceAll (build .DockerfileInline , "${" , "$${" ),
212216 Args : args ,
213217 Labels : labels ,
214- Tags : append (build .Tags , api . GetImageNameOrDefault ( service , project . Name ) ),
218+ Tags : append (build .Tags , image ),
215219
216220 CacheFrom : build .CacheFrom ,
217221 CacheTo : build .CacheTo ,
@@ -363,13 +367,14 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
363367 cw := progress .ContextWriter (ctx )
364368 results := map [string ]string {}
365369 for name := range serviceToBeBuild {
370+ image := expectedImages [name ]
366371 target := targets [name ]
367372 built , ok := md [target ]
368373 if ! ok {
369374 return nil , fmt .Errorf ("build result not found in Bake metadata for service %s" , name )
370375 }
371- results [name ] = built .Digest
372- cw .Event (progress .BuiltEvent (name ))
376+ results [image ] = built .Digest
377+ cw .Event (progress .BuiltEvent (image ))
373378 }
374379 return results , nil
375380}
0 commit comments