only build requested services

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-08-26 14:57:43 +02:00
parent 6a6dafbdb5
commit 19cbbdd79e
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
3 changed files with 10 additions and 2 deletions

View File

@ -94,5 +94,6 @@ func runBuild(ctx context.Context, backend api.Service, opts buildOptions, servi
Args: types.NewMappingWithEquals(opts.args),
NoCache: opts.noCache,
Quiet: opts.quiet,
Services: services,
})
}

View File

@ -90,6 +90,8 @@ type BuildOptions struct {
NoCache bool
// Quiet make the build process not output to the console
Quiet bool
// Services passed in the command line to be built
Services []string
}
// CreateOptions group options of the Create API

View File

@ -53,7 +53,12 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
return s, ok
}))
for _, service := range project.Services {
services, err := project.GetServices(options.Services...)
if err != nil {
return err
}
for _, service := range services {
if service.Build != nil {
imageName := getImageName(service, project.Name)
imagesToBuild = append(imagesToBuild, imageName)
@ -79,7 +84,7 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
}
}
_, err := s.doBuild(ctx, project, opts, options.Progress)
_, err = s.doBuild(ctx, project, opts, options.Progress)
if err == nil {
if len(imagesToBuild) > 0 && !options.Quiet {
utils.DisplayScanSuggestMsg()