mirror of https://github.com/docker/compose.git
Merge pull request #2044 from ndeloof/build_services
Only build requested services
This commit is contained in:
commit
52df801287
|
@ -94,5 +94,6 @@ func runBuild(ctx context.Context, backend api.Service, opts buildOptions, servi
|
||||||
Args: types.NewMappingWithEquals(opts.args),
|
Args: types.NewMappingWithEquals(opts.args),
|
||||||
NoCache: opts.noCache,
|
NoCache: opts.noCache,
|
||||||
Quiet: opts.quiet,
|
Quiet: opts.quiet,
|
||||||
|
Services: services,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,8 @@ type BuildOptions struct {
|
||||||
NoCache bool
|
NoCache bool
|
||||||
// Quiet make the build process not output to the console
|
// Quiet make the build process not output to the console
|
||||||
Quiet bool
|
Quiet bool
|
||||||
|
// Services passed in the command line to be built
|
||||||
|
Services []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOptions group options of the Create API
|
// CreateOptions group options of the Create API
|
||||||
|
|
|
@ -53,7 +53,12 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
||||||
return s, ok
|
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 {
|
if service.Build != nil {
|
||||||
imageName := getImageName(service, project.Name)
|
imageName := getImageName(service, project.Name)
|
||||||
imagesToBuild = append(imagesToBuild, imageName)
|
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 err == nil {
|
||||||
if len(imagesToBuild) > 0 && !options.Quiet {
|
if len(imagesToBuild) > 0 && !options.Quiet {
|
||||||
utils.DisplayScanSuggestMsg()
|
utils.DisplayScanSuggestMsg()
|
||||||
|
|
Loading…
Reference in New Issue