mirror of
https://github.com/docker/compose.git
synced 2025-07-07 13:54:34 +02:00
Avoid pulling same images multiple times ⚡️
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
This commit is contained in:
parent
10ca0314bc
commit
d62c9fe842
@ -21,6 +21,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -59,16 +60,44 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
|
|||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
var mustBuild []string
|
var mustBuild []string
|
||||||
|
|
||||||
|
images, err := s.getLocalImagesDigests(ctx, project)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
imagesBeingPulled := map[string]string{}
|
||||||
|
|
||||||
for _, service := range project.Services {
|
for _, service := range project.Services {
|
||||||
service := service
|
service := service
|
||||||
if service.Image == "" {
|
if service.Image == "" {
|
||||||
w.Event(progress.Event{
|
w.Event(progress.Event{
|
||||||
ID: service.Name,
|
ID: service.Name,
|
||||||
Status: progress.Done,
|
Status: progress.Done,
|
||||||
Text: "Skipped",
|
Text: "Skipped - No image to be pulled",
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := images[service.Image]; ok {
|
||||||
|
w.Event(progress.Event{
|
||||||
|
ID: service.Name,
|
||||||
|
Status: progress.Done,
|
||||||
|
Text: "Skipped - Image is already present locally",
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if s, ok := imagesBeingPulled[service.Image]; ok {
|
||||||
|
w.Event(progress.Event{
|
||||||
|
ID: service.Name,
|
||||||
|
Status: progress.Done,
|
||||||
|
Text: fmt.Sprintf("Skipped - Image is already being pulled by %v", s),
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
imagesBeingPulled[service.Image] = service.Name
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
err := s.pullServiceImage(ctx, service, info, s.configFile, w, false)
|
err := s.pullServiceImage(ctx, service, info, s.configFile, w, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user