@@ -111,7 +111,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
111
111
if quietPull {
112
112
mode = xprogress .PrinterModeQuiet
113
113
}
114
- opts , err := s .getBuildOptions (project , images )
114
+ opts , imagesToBuild , err := s .getBuildOptions (project , images )
115
115
if err != nil {
116
116
return err
117
117
}
@@ -120,7 +120,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
120
120
return err
121
121
}
122
122
123
- if len (builtImages ) > 0 {
123
+ if len (imagesToBuild ) > 0 {
124
124
utils .DisplayScanSuggestMsg ()
125
125
}
126
126
for name , digest := range builtImages {
@@ -130,17 +130,18 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
130
130
for i , service := range project .Services {
131
131
digest , ok := images [getImageName (service , project .Name )]
132
132
if ok {
133
- project .Services [i ].Labels [ api . ImageDigestLabel ] = digest
133
+ project .Services [i ].Image = digest
134
134
}
135
135
}
136
136
return nil
137
137
}
138
138
139
- func (s * composeService ) getBuildOptions (project * types.Project , images map [string ]string ) (map [string ]build.Options , error ) {
139
+ func (s * composeService ) getBuildOptions (project * types.Project , images map [string ]string ) (map [string ]build.Options , [] string , error ) {
140
140
opts := map [string ]build.Options {}
141
+ imagesToBuild := []string {}
141
142
for _ , service := range project .Services {
142
143
if service .Image == "" && service .Build == nil {
143
- return nil , fmt .Errorf ("invalid service %q. Must specify either image or build" , service .Name )
144
+ return nil , nil , fmt .Errorf ("invalid service %q. Must specify either image or build" , service .Name )
144
145
}
145
146
imageName := getImageName (service , project .Name )
146
147
_ , localImagePresent := images [imageName ]
@@ -149,15 +150,16 @@ func (s *composeService) getBuildOptions(project *types.Project, images map[stri
149
150
if localImagePresent && service .PullPolicy != types .PullPolicyBuild {
150
151
continue
151
152
}
153
+ imagesToBuild = append (imagesToBuild , imageName )
152
154
opt , err := s .toBuildOptions (project , service , imageName )
153
155
if err != nil {
154
- return nil , err
156
+ return nil , nil , err
155
157
}
156
158
opts [imageName ] = opt
157
159
continue
158
160
}
159
161
}
160
- return opts , nil
162
+ return opts , imagesToBuild , nil
161
163
162
164
}
163
165
0 commit comments