Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 19cbbdd

Browse files
committed
only build requested services
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 6a6dafb commit 19cbbdd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

cmd/compose/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ func runBuild(ctx context.Context, backend api.Service, opts buildOptions, servi
9494
Args: types.NewMappingWithEquals(opts.args),
9595
NoCache: opts.noCache,
9696
Quiet: opts.quiet,
97+
Services: services,
9798
})
9899
}

pkg/api/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ type BuildOptions struct {
9090
NoCache bool
9191
// Quiet make the build process not output to the console
9292
Quiet bool
93+
// Services passed in the command line to be built
94+
Services []string
9395
}
9496

9597
// CreateOptions group options of the Create API

pkg/compose/build.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
5353
return s, ok
5454
}))
5555

56-
for _, service := range project.Services {
56+
services, err := project.GetServices(options.Services...)
57+
if err != nil {
58+
return err
59+
}
60+
61+
for _, service := range services {
5762
if service.Build != nil {
5863
imageName := getImageName(service, project.Name)
5964
imagesToBuild = append(imagesToBuild, imageName)
@@ -79,7 +84,7 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
7984
}
8085
}
8186

82-
_, err := s.doBuild(ctx, project, opts, options.Progress)
87+
_, err = s.doBuild(ctx, project, opts, options.Progress)
8388
if err == nil {
8489
if len(imagesToBuild) > 0 && !options.Quiet {
8590
utils.DisplayScanSuggestMsg()

0 commit comments

Comments
 (0)