Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
This commit is contained in:
Suleiman Dibirov
2025-10-28 17:22:49 +02:00
committed by Guillaume Lours
parent 0c854a6ab7
commit 6a35be5112

View File

@@ -98,13 +98,7 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
Add(api.OneoffLabel, "True")
// Only ensure image exists for the target service, dependencies were already handled by startDependencies
var buildOpts *api.BuildOptions
if opts.Build != nil {
// Create a copy of build options and restrict to only the target service
buildOptsCopy := *opts.Build
buildOptsCopy.Services = []string{opts.Service}
buildOpts = &buildOptsCopy
}
buildOpts := prepareBuildOptions(opts)
if err := s.ensureImagesExists(ctx, project, buildOpts, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
return "", err
}
@@ -155,6 +149,16 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
return created.ID, err
}
func prepareBuildOptions(opts api.RunOptions) *api.BuildOptions {
if opts.Build == nil {
return nil
}
// Create a copy of build options and restrict to only the target service
buildOptsCopy := *opts.Build
buildOptsCopy.Services = []string{opts.Service}
return &buildOptsCopy
}
func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts api.RunOptions) {
service.Tty = opts.Tty
service.StdinOpen = opts.Interactive