@@ -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
@@ -202,6 +203,9 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
202203 }
203204 }
204205
206+ image := api .GetImageNameOrDefault (service , project .Name )
207+ expectedImages [serviceName ] = image
208+
205209 target := targets [serviceName ]
206210 cfg .Targets [target ] = bakeTarget {
207211 Context : build .Context ,
@@ -210,7 +214,7 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
210214 DockerfileInline : strings .ReplaceAll (build .DockerfileInline , "${" , "$${" ),
211215 Args : args ,
212216 Labels : build .Labels ,
213- Tags : append (build .Tags , api . GetImageNameOrDefault ( service , project . Name ) ),
217+ Tags : append (build .Tags , image ),
214218
215219 CacheFrom : build .CacheFrom ,
216220 CacheTo : build .CacheTo ,
@@ -362,13 +366,14 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
362366 cw := progress .ContextWriter (ctx )
363367 results := map [string ]string {}
364368 for name := range serviceToBeBuild {
369+ image := expectedImages [name ]
365370 target := targets [name ]
366371 built , ok := md [target ]
367372 if ! ok {
368373 return nil , fmt .Errorf ("build result not found in Bake metadata for service %s" , name )
369374 }
370- results [name ] = built .Digest
371- cw .Event (progress .BuiltEvent (name ))
375+ results [image ] = built .Digest
376+ cw .Event (progress .BuiltEvent (image ))
372377 }
373378 return results , nil
374379}
0 commit comments