mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-04 10:27:43 +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 |
|
| Flag | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| -f, --file stringArray | Build definition file
|
| -f, --file stringArray | Build definition file
|
||||||
|
| --load | Shorthand for --set=*.output=type=docker
|
||||||
| --no-cache | Do not use cache when building the image
|
| --no-cache | Do not use cache when building the image
|
||||||
| --print | Print the options without building
|
| --print | Print the options without building
|
||||||
| --progress string | Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto")
|
| --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
|
| --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)
|
| --set stringArray | Override target value (eg: targetpattern.key=value)
|
||||||
|
|
||||||
#### `-f, --file FILE`
|
#### `-f, --file FILE`
|
||||||
|
@ -37,7 +37,17 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions) error {
|
|||||||
targets = []string{"default"}
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -100,6 +110,8 @@ func bakeCmd(dockerCli command.Cli) *cobra.Command {
|
|||||||
flags.StringArrayVarP(&options.files, "file", "f", []string{}, "Build definition file")
|
flags.StringArrayVarP(&options.files, "file", "f", []string{}, "Build definition file")
|
||||||
flags.BoolVar(&options.printOnly, "print", false, "Print the options without building")
|
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.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)
|
commonFlags(&options.commonOptions, flags)
|
||||||
|
|
||||||
|
@ -38,9 +38,6 @@ type buildOptions struct {
|
|||||||
extraHosts []string
|
extraHosts []string
|
||||||
networkMode string
|
networkMode string
|
||||||
|
|
||||||
exportPush bool
|
|
||||||
exportLoad bool
|
|
||||||
|
|
||||||
// unimplemented
|
// unimplemented
|
||||||
squash bool
|
squash bool
|
||||||
quiet bool
|
quiet bool
|
||||||
@ -68,6 +65,8 @@ type commonOptions struct {
|
|||||||
noCache bool
|
noCache bool
|
||||||
progress string
|
progress string
|
||||||
pull bool
|
pull bool
|
||||||
|
exportPush bool
|
||||||
|
exportLoad bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBuild(dockerCli command.Cli, in buildOptions) error {
|
func runBuild(dockerCli command.Cli, in buildOptions) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user