@@ -141,10 +141,11 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
141
141
Targets : map [string ]bakeTarget {},
142
142
}
143
143
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
148
149
)
149
150
150
151
// produce a unique ID for service used as bake target
@@ -203,6 +204,9 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
203
204
}
204
205
}
205
206
207
+ image := api .GetImageNameOrDefault (service , project .Name )
208
+ expectedImages [serviceName ] = image
209
+
206
210
target := targets [serviceName ]
207
211
cfg .Targets [target ] = bakeTarget {
208
212
Context : build .Context ,
@@ -211,7 +215,7 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
211
215
DockerfileInline : strings .ReplaceAll (build .DockerfileInline , "${" , "$${" ),
212
216
Args : args ,
213
217
Labels : labels ,
214
- Tags : append (build .Tags , api . GetImageNameOrDefault ( service , project . Name ) ),
218
+ Tags : append (build .Tags , image ),
215
219
216
220
CacheFrom : build .CacheFrom ,
217
221
CacheTo : build .CacheTo ,
@@ -363,13 +367,14 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
363
367
cw := progress .ContextWriter (ctx )
364
368
results := map [string ]string {}
365
369
for name := range serviceToBeBuild {
370
+ image := expectedImages [name ]
366
371
target := targets [name ]
367
372
built , ok := md [target ]
368
373
if ! ok {
369
374
return nil , fmt .Errorf ("build result not found in Bake metadata for service %s" , name )
370
375
}
371
- results [name ] = built .Digest
372
- cw .Event (progress .BuiltEvent (name ))
376
+ results [image ] = built .Digest
377
+ cw .Event (progress .BuiltEvent (image ))
373
378
}
374
379
return results , nil
375
380
}
0 commit comments