Skip to content

Commit 3072fd0

Browse files
authored
Merge pull request #19749 from dvdksn/bake-auth-remote-def
bake: remote auth variables
2 parents 0819d25 + b0847cd commit 3072fd0

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

content/build/bake/remote-definition.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,19 @@ docker buildx bake -f bake.hcl -f cwd://local.hcl "https://github.com/crazy-max/
179179
}
180180
}
181181
```
182+
183+
## Remote definition in a private repository
184+
185+
If you want to use a remote definition that lives in a private repository,
186+
you may need to specify credentials for Bake to use when fetching the definition.
187+
188+
If you can authenticate to the private repository using the default `SSH_AUTH_SOCK`,
189+
then you don't need to specify any additional authentication parameters for Bake.
190+
Bake automatically uses your default agent socket.
191+
192+
For authentication using an HTTP token, or custom SSH agents,
193+
use the following environment variables to configure Bake's authentication strategy:
194+
195+
- [`BUILDX_BAKE_GIT_AUTH_TOKEN`](../building/variables.md#buildx_bake_git_auth_token)
196+
- [`BUILDX_BAKE_GIT_AUTH_HEADER`](../building/variables.md#buildx_bake_git_auth_header)
197+
- [`BUILDX_BAKE_GIT_SSH`](../building/variables.md#buildx_bake_git_ssh)

content/build/building/variables.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ They're used to configure the Buildx client, or the BuildKit daemon.
308308
| [BUILDKIT_HOST](#buildkit_host) | String | Specify host to use for remote builders. |
309309
| [BUILDKIT_PROGRESS](#buildkit_progress) | String | Configure type of progress output. |
310310
| [BUILDKIT_TTY_LOG_LINES](#buildkit_tty_log_lines) | String | Number of log lines (for active steps in tty mode). |
311+
| [BUILDX_BAKE_GIT_AUTH_HEADER](#buildx_bake_git_auth_header) | String | HTTP authentication scheme for remote Bake files. |
312+
| [BUILDX_BAKE_GIT_AUTH_TOKEN](#buildx_bake_git_auth_token) | String | HTTP authentication token for remote Bake files. |
313+
| [BUILDX_BAKE_GIT_SSH](#buildx_bake_git_ssh) | String | SSH authentication for remote Bake files. |
311314
| [BUILDX_BUILDER](#buildx_builder) | String | Specify the builder instance to use. |
312315
| [BUILDX_CONFIG](#buildx_config) | String | Specify location for configuration, state, and logs. |
313316
| [BUILDX_EXPERIMENTAL](#buildx_experimental) | Boolean | Turn on experimental features. |
@@ -326,6 +329,8 @@ For example, `true`, `1`, and `T` all evaluate to true.
326329
Evaluation is done using the `strconv.ParseBool` function in the Go standard library.
327330
See the [reference documentation](https://pkg.go.dev/strconv#ParseBool) for details.
328331

332+
<!-- vale Docker.HeadingSentenceCase = NO -->
333+
329334
### BUILDKIT_COLORS
330335

331336
Changes the colors of the terminal output. Set `BUILDKIT_COLORS` to a CSV string
@@ -426,6 +431,53 @@ Example:
426431
}
427432
```
428433

434+
### BUILDX_BAKE_GIT_AUTH_HEADER
435+
436+
{{< introduced buildx 0.14.0 >}}
437+
438+
Sets the HTTP authentication scheme when using a remote Bake definition in a private Git repository.
439+
This is equivalent to the [`GIT_AUTH_HEADER` secret](./secrets#http-authentication-scheme),
440+
but facilitates the pre-flight authentication in Bake when loading the remote Bake file.
441+
Supported values are `bearer` (default) and `basic`.
442+
443+
Usage:
444+
445+
```console
446+
$ export BUILDX_BAKE_GIT_AUTH_HEADER=basic
447+
```
448+
449+
### BUILDX_BAKE_GIT_AUTH_TOKEN
450+
451+
{{< introduced buildx 0.14.0 >}}
452+
453+
Sets the HTTP authentication token when using a remote Bake definition in a private Git repository.
454+
This is equivalent to the [`GIT_AUTH_TOKEN` secret](./secrets#git-authentication-for-remote-contexts),
455+
but facilitates the pre-flight authentication in Bake when loading the remote Bake file.
456+
457+
Usage:
458+
459+
```console
460+
$ export BUILDX_BAKE_GIT_AUTH_TOKEN=$(cat git-token.txt)
461+
```
462+
463+
### BUILDX_BAKE_GIT_SSH
464+
465+
{{< introduced buildx 0.14.0 >}}
466+
467+
Lets you specify a list of SSH agent socket filepaths to forward to Bake
468+
for authenticating to a Git server when using a remote Bake definition in a private repository.
469+
This is similar to SSH mounts for builds, but facilitates the pre-flight authentication in Bake when resolving the build definition.
470+
471+
Setting this environment is typically not necessary, because Bake will use the `SSH_AUTH_SOCK` agent socket by default.
472+
You only need to specify this variable if you want to use a socket with a different filepath.
473+
This variable can take multiple paths using a comma-separated string.
474+
475+
Usage:
476+
477+
```console
478+
$ export BUILDX_BAKE_GIT_SSH=/run/foo/listener.sock,~/.creds/ssh.sock
479+
```
480+
429481
### BUILDX_BUILDER
430482

431483
Overrides the configured builder instance. Same as the `docker buildx --builder`
@@ -545,3 +597,4 @@ Usage:
545597
$ export BUILDX_NO_DEFAULT_LOAD=1
546598
```
547599

600+
<!-- vale Docker.HeadingSentenceCase = YES -->

0 commit comments

Comments
 (0)