mirror of https://github.com/docker/compose.git
collect built image IDs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
bbe1b77a67
commit
e492330dd5
|
@ -52,11 +52,15 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
|
|||
func (s *composeService) build(ctx context.Context, project *types.Project, options api.BuildOptions) (map[string]string, error) {
|
||||
args := flatten(options.Args.Resolve(envResolver(project.Environment)))
|
||||
|
||||
var imageIDs map[string]string
|
||||
builtIDs := make([]string, len(project.Services))
|
||||
err := InDependencyOrder(ctx, project, func(ctx context.Context, name string) error {
|
||||
if len(options.Services) > 0 && !utils.Contains(options.Services, name) {
|
||||
return nil
|
||||
}
|
||||
for i, service := range project.Services {
|
||||
if service.Name != name {
|
||||
continue
|
||||
}
|
||||
service, err := project.GetService(name)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -98,11 +102,23 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
|||
}}
|
||||
}
|
||||
opts := map[string]build.Options{imageName: buildOptions}
|
||||
imageIDs, err = s.doBuild(ctx, project, opts, options.Progress)
|
||||
ids, err := s.doBuild(ctx, project, opts, options.Progress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
builtIDs[i] = ids[imageName]
|
||||
}
|
||||
return nil
|
||||
}, func(traversal *graphTraversal) {
|
||||
traversal.maxConcurrency = s.maxConcurrency
|
||||
})
|
||||
|
||||
imageIDs := map[string]string{}
|
||||
for i, d := range builtIDs {
|
||||
if d != "" {
|
||||
imageIDs[project.Services[i].Image] = d
|
||||
}
|
||||
}
|
||||
return imageIDs, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue