build: add --frontend flag

Allow for specifying a custom frontend image as a command line
argument using the gateway.v0 frontend.

Signed-off-by: Justin Chadwell <me@jedevc.com>
pull/1061/head
Justin Chadwell 3 years ago
parent b8bcf1d810
commit 45437f1dd3

@ -63,6 +63,7 @@ type Options struct {
CgroupParent string
Exports []client.ExportEntry
ExtraHosts []string
Frontend string
ImageIDFile string
Labels map[string]string
NetworkMode string
@ -415,6 +416,11 @@ func toSolveOpt(ctx context.Context, di DriverInfo, multiDriver bool, opt Option
AllowedEntitlements: opt.Allow,
}
if opt.Frontend != "" {
so.Frontend = "gateway.v0"
so.FrontendAttrs["source"] = opt.Frontend
}
if opt.CgroupParent != "" {
so.FrontendAttrs["cgroup-parent"] = opt.CgroupParent
}

@ -50,6 +50,7 @@ type buildOptions struct {
cgroupParent string
contexts []string
extraHosts []string
frontend string
imageIDFile string
labels []string
networkMode string
@ -125,6 +126,7 @@ func runBuild(dockerCli command.Cli, in buildOptions) (err error) {
BuildArgs: listToMap(in.buildArgs, true),
ExtraHosts: in.extraHosts,
ImageIDFile: in.imageIDFile,
Frontend: in.frontend,
Labels: listToMap(in.labels, false),
NetworkMode: in.networkMode,
NoCache: noCache,
@ -359,6 +361,8 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
flags.StringVar(&options.imageIDFile, "iidfile", "", "Write the image ID to the file")
flags.StringVar(&options.frontend, "frontend", "", "Set custom frontend to use for build")
flags.StringArrayVar(&options.labels, "label", []string{}, "Set metadata for an image")
flags.BoolVar(&options.exportLoad, "load", false, `Shorthand for "--output=type=docker"`)

@ -24,6 +24,7 @@ Start a build
| [`--cache-to`](#cache-to) | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
| [`--cgroup-parent`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | `string` | | Optional parent cgroup for the container |
| [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
| `--frontend` | `string` | | Set custom frontend to use for build |
| `--iidfile` | `string` | | Write the image ID to the file |
| `--label` | `stringArray` | | Set metadata for an image |
| [`--load`](#load) | | | Shorthand for `--output=type=docker` |

Loading…
Cancel
Save