mirror of https://github.com/docker/compose.git
Support for docker compose build --push when using multiple platforms
Signed-off-by: maxcleme <maxime.clement@docker.com>
This commit is contained in:
parent
cf12239547
commit
634a7d2a7b
|
@ -38,6 +38,7 @@ type buildOptions struct {
|
||||||
composeOptions
|
composeOptions
|
||||||
quiet bool
|
quiet bool
|
||||||
pull bool
|
pull bool
|
||||||
|
push bool
|
||||||
progress string
|
progress string
|
||||||
args []string
|
args []string
|
||||||
noCache bool
|
noCache bool
|
||||||
|
@ -57,6 +58,7 @@ func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions,
|
||||||
|
|
||||||
return api.BuildOptions{
|
return api.BuildOptions{
|
||||||
Pull: opts.pull,
|
Pull: opts.pull,
|
||||||
|
Push: opts.push,
|
||||||
Progress: opts.progress,
|
Progress: opts.progress,
|
||||||
Args: types.NewMappingWithEquals(opts.args),
|
Args: types.NewMappingWithEquals(opts.args),
|
||||||
NoCache: opts.noCache,
|
NoCache: opts.noCache,
|
||||||
|
@ -108,6 +110,7 @@ func buildCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *
|
||||||
}),
|
}),
|
||||||
ValidArgsFunction: completeServiceNames(p),
|
ValidArgsFunction: completeServiceNames(p),
|
||||||
}
|
}
|
||||||
|
cmd.Flags().BoolVar(&opts.push, "push", false, "Push service images.")
|
||||||
cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
|
cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
|
||||||
cmd.Flags().BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image.")
|
cmd.Flags().BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image.")
|
||||||
cmd.Flags().StringVar(&opts.progress, "progress", buildx.PrinterModeAuto, fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
|
cmd.Flags().StringVar(&opts.progress, "progress", buildx.PrinterModeAuto, fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
|
||||||
|
|
|
@ -11,6 +11,7 @@ Build or rebuild services
|
||||||
| `--no-cache` | | | Do not use cache when building the image |
|
| `--no-cache` | | | Do not use cache when building the image |
|
||||||
| `--progress` | `string` | `auto` | Set type of progress output (auto, tty, plain, quiet) |
|
| `--progress` | `string` | `auto` | Set type of progress output (auto, tty, plain, quiet) |
|
||||||
| `--pull` | | | Always attempt to pull a newer version of the image. |
|
| `--pull` | | | Always attempt to pull a newer version of the image. |
|
||||||
|
| `--push` | | | Push service images. |
|
||||||
| `-q`, `--quiet` | | | Don't print anything to STDOUT |
|
| `-q`, `--quiet` | | | Don't print anything to STDOUT |
|
||||||
| `--ssh` | `string` | | Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent) |
|
| `--ssh` | `string` | | Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent) |
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,16 @@ options:
|
||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: push
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: Push service images.
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
- option: quiet
|
- option: quiet
|
||||||
shorthand: q
|
shorthand: q
|
||||||
value_type: bool
|
value_type: bool
|
||||||
|
|
|
@ -91,6 +91,8 @@ type WatchOptions struct {
|
||||||
type BuildOptions struct {
|
type BuildOptions struct {
|
||||||
// Pull always attempt to pull a newer version of the image
|
// Pull always attempt to pull a newer version of the image
|
||||||
Pull bool
|
Pull bool
|
||||||
|
// Push pushes service images
|
||||||
|
Push bool
|
||||||
// Progress set type of progress output ("auto", "plain", "tty")
|
// Progress set type of progress output ("auto", "plain", "tty")
|
||||||
Progress string
|
Progress string
|
||||||
// Args set build-time args
|
// Args set build-time args
|
||||||
|
|
|
@ -86,12 +86,15 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
||||||
Type: "docker",
|
Type: "docker",
|
||||||
Attrs: map[string]string{
|
Attrs: map[string]string{
|
||||||
"load": "true",
|
"load": "true",
|
||||||
|
"push": fmt.Sprint(options.Push),
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
if len(buildOptions.Platforms) > 1 {
|
if len(buildOptions.Platforms) > 1 {
|
||||||
buildOptions.Exports = []bclient.ExportEntry{{
|
buildOptions.Exports = []bclient.ExportEntry{{
|
||||||
Type: "image",
|
Type: "image",
|
||||||
Attrs: map[string]string{},
|
Attrs: map[string]string{
|
||||||
|
"push": fmt.Sprint(options.Push),
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
opts := map[string]build.Options{imageName: buildOptions}
|
opts := map[string]build.Options{imageName: buildOptions}
|
||||||
|
|
|
@ -59,6 +59,12 @@ func (s *composeService) doBuildClassic(ctx context.Context, project *types.Proj
|
||||||
errs = multierror.Append(errs, err).ErrorOrNil()
|
errs = multierror.Append(errs, err).ErrorOrNil()
|
||||||
}
|
}
|
||||||
nameDigests[imageName] = digest
|
nameDigests[imageName] = digest
|
||||||
|
if errs != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if len(o.Exports) != 0 && o.Exports[0].Attrs["push"] == "true" {
|
||||||
|
return s.push(ctx, project, api.PushOptions{})
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue