From ae43081d1d3dd42eebba796cf6f2037a0ecfefab Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 10 Apr 2017 15:27:42 -0700 Subject: [PATCH] builder: add an option for specifying build target Signed-off-by: Tonis Tiigi --- command/image/build.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/command/image/build.go b/command/image/build.go index 5268cbc254..27fe83c524 100644 --- a/command/image/build.go +++ b/command/image/build.go @@ -64,6 +64,7 @@ type buildOptions struct { securityOpt []string networkMode string squash bool + target string } // 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.SetAnnotation("network", "version", []string{"1.25"}) 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) @@ -302,6 +304,7 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error { NetworkMode: options.networkMode, Squash: options.squash, ExtraHosts: options.extraHosts.GetAll(), + Target: options.target, } response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions)