mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +02:00
Revert "introduce ImageDigestLabel to track image built for service"
Signed-off-by: Lorena Rangel <lorena.rangel@docker.com>
This commit is contained in:
parent
fff0ed2bcd
commit
15f07f2e13
@ -47,8 +47,6 @@ const (
|
|||||||
OneoffLabel = "com.docker.compose.oneoff"
|
OneoffLabel = "com.docker.compose.oneoff"
|
||||||
// SlugLabel stores unique slug used for one-off container identity
|
// SlugLabel stores unique slug used for one-off container identity
|
||||||
SlugLabel = "com.docker.compose.slug"
|
SlugLabel = "com.docker.compose.slug"
|
||||||
// ImageDigestLabel stores digest of the container image used to run service
|
|
||||||
ImageDigestLabel = "com.docker.compose.image"
|
|
||||||
// VersionLabel stores the compose tool version used to run application
|
// VersionLabel stores the compose tool version used to run application
|
||||||
VersionLabel = "com.docker.compose.version"
|
VersionLabel = "com.docker.compose.version"
|
||||||
)
|
)
|
||||||
|
@ -111,7 +111,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
|
|||||||
if quietPull {
|
if quietPull {
|
||||||
mode = xprogress.PrinterModeQuiet
|
mode = xprogress.PrinterModeQuiet
|
||||||
}
|
}
|
||||||
opts, err := s.getBuildOptions(project, images)
|
opts, imagesToBuild, err := s.getBuildOptions(project, images)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(builtImages) > 0 {
|
if len(imagesToBuild) > 0 {
|
||||||
utils.DisplayScanSuggestMsg()
|
utils.DisplayScanSuggestMsg()
|
||||||
}
|
}
|
||||||
for name, digest := range builtImages {
|
for name, digest := range builtImages {
|
||||||
@ -130,17 +130,18 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
|
|||||||
for i, service := range project.Services {
|
for i, service := range project.Services {
|
||||||
digest, ok := images[getImageName(service, project.Name)]
|
digest, ok := images[getImageName(service, project.Name)]
|
||||||
if ok {
|
if ok {
|
||||||
project.Services[i].Labels[api.ImageDigestLabel] = digest
|
project.Services[i].Image = digest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) getBuildOptions(project *types.Project, images map[string]string) (map[string]build.Options, error) {
|
func (s *composeService) getBuildOptions(project *types.Project, images map[string]string) (map[string]build.Options, []string, error) {
|
||||||
opts := map[string]build.Options{}
|
opts := map[string]build.Options{}
|
||||||
|
imagesToBuild := []string{}
|
||||||
for _, service := range project.Services {
|
for _, service := range project.Services {
|
||||||
if service.Image == "" && service.Build == nil {
|
if service.Image == "" && service.Build == nil {
|
||||||
return nil, fmt.Errorf("invalid service %q. Must specify either image or build", service.Name)
|
return nil, nil, fmt.Errorf("invalid service %q. Must specify either image or build", service.Name)
|
||||||
}
|
}
|
||||||
imageName := getImageName(service, project.Name)
|
imageName := getImageName(service, project.Name)
|
||||||
_, localImagePresent := images[imageName]
|
_, localImagePresent := images[imageName]
|
||||||
@ -149,15 +150,16 @@ func (s *composeService) getBuildOptions(project *types.Project, images map[stri
|
|||||||
if localImagePresent && service.PullPolicy != types.PullPolicyBuild {
|
if localImagePresent && service.PullPolicy != types.PullPolicyBuild {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
imagesToBuild = append(imagesToBuild, imageName)
|
||||||
opt, err := s.toBuildOptions(project, service, imageName)
|
opt, err := s.toBuildOptions(project, service, imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
opts[imageName] = opt
|
opts[imageName] = opt
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return opts, nil
|
return opts, imagesToBuild, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user