mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
Add option to build/bake to override instance
This helps prevent race conditions with concurrent build invocations. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@ -63,11 +63,13 @@ type buildOptions struct {
|
||||
}
|
||||
|
||||
type commonOptions struct {
|
||||
builderOptions
|
||||
noCache *bool
|
||||
progress string
|
||||
pull *bool
|
||||
exportPush bool
|
||||
exportLoad bool
|
||||
builder string
|
||||
}
|
||||
|
||||
func runBuild(dockerCli command.Cli, in buildOptions) error {
|
||||
@ -191,11 +193,11 @@ func runBuild(dockerCli command.Cli, in buildOptions) error {
|
||||
contextPathHash = in.contextPath
|
||||
}
|
||||
|
||||
return buildTargets(ctx, dockerCli, map[string]build.Options{"default": opts}, in.progress, contextPathHash)
|
||||
return buildTargets(ctx, dockerCli, map[string]build.Options{"default": opts}, in.progress, contextPathHash, in.builder)
|
||||
}
|
||||
|
||||
func buildTargets(ctx context.Context, dockerCli command.Cli, opts map[string]build.Options, progressMode, contextPathHash string) error {
|
||||
dis, err := getDefaultDrivers(ctx, dockerCli, contextPathHash)
|
||||
func buildTargets(ctx context.Context, dockerCli command.Cli, opts map[string]build.Options, progressMode, contextPathHash, instance string) error {
|
||||
dis, err := getInstanceOrDefault(ctx, dockerCli, instance, contextPathHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -297,12 +299,13 @@ func buildCmd(dockerCli command.Cli) *cobra.Command {
|
||||
|
||||
flags.StringArrayVarP(&options.outputs, "output", "o", []string{}, "Output destination (format: type=local,dest=path)")
|
||||
|
||||
commonFlags(&options.commonOptions, flags)
|
||||
commonBuildFlags(&options.commonOptions, flags)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func commonFlags(options *commonOptions, flags *pflag.FlagSet) {
|
||||
func commonBuildFlags(options *commonOptions, flags *pflag.FlagSet) {
|
||||
builderFlags(&options.builderOptions, flags)
|
||||
flags.Var(flagutil.Tristate(options.noCache), "no-cache", "Do not use cache when building the image")
|
||||
flags.StringVar(&options.progress, "progress", "auto", "Set type of progress output (auto, plain, tty). Use plain to show container output")
|
||||
flags.Var(flagutil.Tristate(options.pull), "pull", "Always attempt to pull a newer version of the image")
|
||||
|
Reference in New Issue
Block a user