Skip to content

Commit b3207c4

Browse files
ndeloofglours
authored andcommitted
setting buildOptions.Services triggers image to be always rebuilt
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 769b739 commit b3207c4

2 files changed

Lines changed: 4 additions & 19 deletions

File tree

cmd/compose/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
282282

283283
var buildForRun *api.BuildOptions
284284
if !createOpts.noBuild {
285-
bo, err := buildOpts.toAPIBuildOptions(project.ServiceNames())
285+
bo, err := buildOpts.toAPIBuildOptions(nil)
286286
if err != nil {
287287
return err
288288
}

pkg/compose/run.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,9 @@ func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts
176176
}
177177

178178
func (s *composeService) startDependencies(ctx context.Context, project *types.Project, options api.RunOptions) error {
179-
dependencies := types.Services{}
180-
var requestedService types.ServiceConfig
181-
for name, service := range project.Services {
182-
if name != options.Service {
183-
dependencies[name] = service
184-
} else {
185-
requestedService = service
186-
}
187-
}
188-
189-
if len(dependencies) > 0 {
190-
project.Services = dependencies
191-
project.DisabledServices[options.Service] = requestedService
192-
}
193-
project.DisabledServices[options.Service] = requestedService
194-
delete(project.Services, options.Service)
179+
project = project.WithServicesDisabled(options.Service)
195180

196-
err = s.Create(ctx, project, api.CreateOptions{
181+
err := s.Create(ctx, project, api.CreateOptions{
197182
Build: options.Build,
198183
IgnoreOrphans: options.IgnoreOrphans,
199184
RemoveOrphans: options.RemoveOrphans,
@@ -203,7 +188,7 @@ func (s *composeService) startDependencies(ctx context.Context, project *types.P
203188
return err
204189
}
205190

206-
if len(dependencies) > 0 {
191+
if len(project.Services) > 0 {
207192
return s.Start(ctx, project.Name, api.StartOptions{
208193
Project: project,
209194
})

0 commit comments

Comments
 (0)