mirror of https://github.com/docker/cli.git
Merge pull request #32496 from tonistiigi/build-target
builder: add an option for specifying build target
This commit is contained in:
commit
f2b5c1e4c6
|
@ -64,6 +64,7 @@ type buildOptions struct {
|
||||||
securityOpt []string
|
securityOpt []string
|
||||||
networkMode string
|
networkMode string
|
||||||
squash bool
|
squash bool
|
||||||
|
target string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBuildCommand creates a new `docker build` command
|
// NewBuildCommand creates a new `docker build` command
|
||||||
|
@ -115,6 +116,7 @@ func NewBuildCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags.StringVar(&options.networkMode, "network", "default", "Set the networking mode for the RUN instructions during build")
|
flags.StringVar(&options.networkMode, "network", "default", "Set the networking mode for the RUN instructions during build")
|
||||||
flags.SetAnnotation("network", "version", []string{"1.25"})
|
flags.SetAnnotation("network", "version", []string{"1.25"})
|
||||||
flags.Var(&options.extraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)")
|
flags.Var(&options.extraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)")
|
||||||
|
flags.StringVar(&options.target, "target", "", "Set the target build stage to build.")
|
||||||
|
|
||||||
command.AddTrustVerificationFlags(flags)
|
command.AddTrustVerificationFlags(flags)
|
||||||
|
|
||||||
|
@ -302,6 +304,7 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error {
|
||||||
NetworkMode: options.networkMode,
|
NetworkMode: options.networkMode,
|
||||||
Squash: options.squash,
|
Squash: options.squash,
|
||||||
ExtraHosts: options.extraHosts.GetAll(),
|
ExtraHosts: options.extraHosts.GetAll(),
|
||||||
|
Target: options.target,
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions)
|
response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions)
|
||||||
|
|
Loading…
Reference in New Issue