Forráskód Böngészése

Merge pull request #2044 from ndeloof/build_services

Only build requested services
Lorena Rangel 4 éve
szülő
commit
52df801287
3 módosított fájl, 10 hozzáadás és 2 törlés
  1. 1 0
      cmd/compose/build.go
  2. 2 0
      pkg/api/api.go
  3. 7 2
      pkg/compose/build.go

+ 1 - 0
cmd/compose/build.go

@@ -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,
 	})
 }

+ 2 - 0
pkg/api/api.go

@@ -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

+ 7 - 2
pkg/compose/build.go

@@ -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()