mirror of
https://github.com/docker/compose.git
synced 2025-07-16 18:24:26 +02:00
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) {
|
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)))
|
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 {
|
err := InDependencyOrder(ctx, project, func(ctx context.Context, name string) error {
|
||||||
if len(options.Services) > 0 && !utils.Contains(options.Services, name) {
|
if len(options.Services) > 0 && !utils.Contains(options.Services, name) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
for i, service := range project.Services {
|
||||||
|
if service.Name != name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
service, err := project.GetService(name)
|
service, err := project.GetService(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -98,11 +102,23 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
opts := map[string]build.Options{imageName: buildOptions}
|
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
|
return err
|
||||||
|
}
|
||||||
|
builtIDs[i] = ids[imageName]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}, func(traversal *graphTraversal) {
|
}, func(traversal *graphTraversal) {
|
||||||
traversal.maxConcurrency = s.maxConcurrency
|
traversal.maxConcurrency = s.maxConcurrency
|
||||||
})
|
})
|
||||||
|
|
||||||
|
imageIDs := map[string]string{}
|
||||||
|
for i, d := range builtIDs {
|
||||||
|
if d != "" {
|
||||||
|
imageIDs[project.Services[i].Image] = d
|
||||||
|
}
|
||||||
|
}
|
||||||
return imageIDs, err
|
return imageIDs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user