mirror of
https://github.com/docker/compose.git
synced 2025-07-21 12:44:54 +02:00
Don't stop pull for images that can be built
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
c342891f3e
commit
0234e13454
@ -31,6 +31,7 @@ import (
|
|||||||
moby "github.com/docker/docker/api/types"
|
moby "github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
|
"github.com/hashicorp/go-multierror"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/docker/compose/v2/pkg/api"
|
"github.com/docker/compose/v2/pkg/api"
|
||||||
@ -65,12 +66,14 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
|
|||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
eg.SetLimit(s.maxConcurrency)
|
eg.SetLimit(s.maxConcurrency)
|
||||||
|
|
||||||
var mustBuild []string
|
var (
|
||||||
|
mustBuild []string
|
||||||
|
pullErrors = make([]error, len(project.Services))
|
||||||
|
imagesBeingPulled = map[string]string{}
|
||||||
|
)
|
||||||
|
|
||||||
imagesBeingPulled := map[string]string{}
|
for i, service := range project.Services {
|
||||||
|
i, service := i, service
|
||||||
for _, service := range project.Services {
|
|
||||||
service := service
|
|
||||||
if service.Image == "" {
|
if service.Image == "" {
|
||||||
w.Event(progress.Event{
|
w.Event(progress.Event{
|
||||||
ID: service.Name,
|
ID: service.Name,
|
||||||
@ -113,13 +116,14 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
|
|||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
_, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
_, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
pullErrors[i] = err
|
||||||
if !opts.IgnoreFailures {
|
if !opts.IgnoreFailures {
|
||||||
if service.Build != nil {
|
if service.Build != nil {
|
||||||
mustBuild = append(mustBuild, service.Name)
|
mustBuild = append(mustBuild, service.Name)
|
||||||
|
} else {
|
||||||
|
return err // fail fast if image can't be pulled nor built
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
w.TailMsgf("Pulling %s: %s", service.Name, err.Error())
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -131,7 +135,11 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
|
|||||||
w.TailMsgf("WARNING: Some service image(s) must be built from source by running:\n docker compose build %s", strings.Join(mustBuild, " "))
|
w.TailMsgf("WARNING: Some service image(s) must be built from source by running:\n docker compose build %s", strings.Join(mustBuild, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return multierror.Append(nil, pullErrors...).ErrorOrNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
func imageAlreadyPresent(serviceImage string, localImages map[string]string) bool {
|
func imageAlreadyPresent(serviceImage string, localImages map[string]string) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user