mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
bake: add --load and --push shorthands for --set
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
2bca8fa677
commit
417f52e001
@ -507,10 +507,12 @@ Options:
|
||||
| Flag | Description |
|
||||
| --- | --- |
|
||||
| -f, --file stringArray | Build definition file
|
||||
| --load | Shorthand for --set=*.output=type=docker
|
||||
| --no-cache | Do not use cache when building the image
|
||||
| --print | Print the options without building
|
||||
| --progress string | Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto")
|
||||
| --pull | Always attempt to pull a newer version of the image
|
||||
| --push | Shorthand for --set=*.output=type=registry
|
||||
| --set stringArray | Override target value (eg: targetpattern.key=value)
|
||||
|
||||
#### `-f, --file FILE`
|
||||
|
@ -37,7 +37,17 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions) error {
|
||||
targets = []string{"default"}
|
||||
}
|
||||
|
||||
m, err := bake.ReadTargets(ctx, in.files, targets, in.overrides)
|
||||
overrides := in.overrides
|
||||
if in.exportPush {
|
||||
if in.exportLoad {
|
||||
return errors.Errorf("push and load may not be set together at the moment")
|
||||
}
|
||||
overrides = append(overrides, "*.output=type=registry")
|
||||
} else if in.exportLoad {
|
||||
overrides = append(overrides, "*.output=type=docker")
|
||||
}
|
||||
|
||||
m, err := bake.ReadTargets(ctx, in.files, targets, overrides)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -100,6 +110,8 @@ func bakeCmd(dockerCli command.Cli) *cobra.Command {
|
||||
flags.StringArrayVarP(&options.files, "file", "f", []string{}, "Build definition file")
|
||||
flags.BoolVar(&options.printOnly, "print", false, "Print the options without building")
|
||||
flags.StringArrayVar(&options.overrides, "set", nil, "Override target value (eg: targetpattern.key=value)")
|
||||
flags.BoolVar(&options.exportPush, "push", false, "Shorthand for --set=*.output=type=registry")
|
||||
flags.BoolVar(&options.exportLoad, "load", false, "Shorthand for --set=*.output=type=docker")
|
||||
|
||||
commonFlags(&options.commonOptions, flags)
|
||||
|
||||
|
@ -38,9 +38,6 @@ type buildOptions struct {
|
||||
extraHosts []string
|
||||
networkMode string
|
||||
|
||||
exportPush bool
|
||||
exportLoad bool
|
||||
|
||||
// unimplemented
|
||||
squash bool
|
||||
quiet bool
|
||||
@ -65,9 +62,11 @@ type buildOptions struct {
|
||||
}
|
||||
|
||||
type commonOptions struct {
|
||||
noCache bool
|
||||
progress string
|
||||
pull bool
|
||||
noCache bool
|
||||
progress string
|
||||
pull bool
|
||||
exportPush bool
|
||||
exportLoad bool
|
||||
}
|
||||
|
||||
func runBuild(dockerCli command.Cli, in buildOptions) error {
|
||||
|
Loading…
Reference in New Issue
Block a user