mirror of
https://github.com/docker/compose.git
synced 2025-07-24 22:24:41 +02:00
collect services to build using WithServices
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
fb3868ffaf
commit
5e61c62ecf
@ -22,7 +22,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/moby/buildkit/util/progress/progressui"
|
"github.com/moby/buildkit/util/progress/progressui"
|
||||||
|
|
||||||
@ -80,30 +79,19 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
|||||||
|
|
||||||
imageIDs := map[string]string{}
|
imageIDs := map[string]string{}
|
||||||
serviceToBeBuild := map[string]serviceToBuild{}
|
serviceToBeBuild := map[string]serviceToBuild{}
|
||||||
mapServiceMutx := sync.Mutex{}
|
err = project.WithServices(options.Services, func(service types.ServiceConfig) error {
|
||||||
err = InDependencyOrder(ctx, project, func(ctx context.Context, name string) error {
|
|
||||||
if len(options.Services) > 0 && !utils.Contains(options.Services, name) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
service := project.Services[name]
|
|
||||||
|
|
||||||
if service.Build == nil {
|
if service.Build == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
image := api.GetImageNameOrDefault(service, project.Name)
|
image := api.GetImageNameOrDefault(service, project.Name)
|
||||||
_, localImagePresent := localImages[image]
|
_, localImagePresent := localImages[image]
|
||||||
if localImagePresent && service.PullPolicy != types.PullPolicyBuild {
|
if localImagePresent && service.PullPolicy != types.PullPolicyBuild {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
mapServiceMutx.Lock()
|
name := service.Name
|
||||||
serviceToBeBuild[name] = serviceToBuild{name: name, service: service}
|
serviceToBeBuild[name] = serviceToBuild{name: name, service: service}
|
||||||
mapServiceMutx.Unlock()
|
|
||||||
return nil
|
return nil
|
||||||
}, func(traversal *graphTraversal) {
|
}, types.IgnoreDependencies)
|
||||||
traversal.maxConcurrency = s.maxConcurrency
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil || len(serviceToBeBuild) == 0 {
|
if err != nil || len(serviceToBeBuild) == 0 {
|
||||||
return imageIDs, err
|
return imageIDs, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user