From 230dfa96a34e63ef0e5d7ac6e42458c216cf6a73 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 13 Feb 2022 00:35:29 +0100 Subject: [PATCH] docs: built-in build args Signed-off-by: CrazyMax --- commands/build.go | 1 - docs/reference/buildx_build.md | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/commands/build.go b/commands/build.go index 5e8110d2..2b00c2c7 100644 --- a/commands/build.go +++ b/commands/build.go @@ -344,7 +344,6 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command { flags.StringSliceVar(&options.allow, "allow", []string{}, `Allow extra privileged entitlement (e.g., "network.host", "security.insecure")`) flags.StringArrayVar(&options.buildArgs, "build-arg", []string{}, "Set build-time variables") - flags.SetAnnotation("build-arg", annotation.ExternalURL, []string{"https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg"}) flags.StringArrayVar(&options.cacheFrom, "cache-from", []string{}, `External cache sources (e.g., "user/app:cache", "type=local,src=path/to/dir")`) diff --git a/docs/reference/buildx_build.md b/docs/reference/buildx_build.md index 274aadac..9631623f 100644 --- a/docs/reference/buildx_build.md +++ b/docs/reference/buildx_build.md @@ -17,7 +17,7 @@ Start a build | --- | --- | | [`--add-host stringSlice`](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) | Add a custom host-to-IP mapping (format: `host:ip`) | | [`--allow stringSlice`](#allow) | Allow extra privileged entitlement (e.g., `network.host`, `security.insecure`) | -| [`--build-arg stringArray`](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) | Set build-time variables | +| [`--build-arg stringArray`](#build-arg) | Set build-time variables | | [`--build-context stringArray`](#build-context) | Additional build contexts (e.g., name=path) | | [`--builder string`](#builder) | Override the configured builder instance | | [`--cache-from stringArray`](#cache-from) | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) | @@ -80,6 +80,22 @@ $ docker buildx create --use --name insecure-builder --buildkitd-flags '--allow- $ docker buildx build --allow security.insecure . ``` +### Set build-time variables (--build-arg) + +Same as [`docker build` command](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg). + +There are also useful built-in build args like: + +* `BUILDKIT_CONTEXT_KEEP_GIT_DIR=` trigger git context to keep the `.git` directory +* `BUILDKIT_INLINE_CACHE=` inline cache metadata to image config or not +* `BUILDKIT_MULTI_PLATFORM=` opt into determnistic output regardless of multi-platform output or not + +```console +$ docker buildx build --build-arg BUILDKIT_MULTI_PLATFORM=1 . +``` + +More built-in build args can be found in [dockerfile frontend docs](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#built-in-build-args). + ### Additional build contexts (--build-context) ```