Skip to content

Commit b646761

Browse files
committed
buildinfo: add BUILDKIT_BUILDINFO build arg
Signed-off-by: CrazyMax <[email protected]>
1 parent 031b9f6 commit b646761

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

control/control.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,15 @@ func (c *Controller) Solve(ctx context.Context, req *controlapi.SolveRequest) (*
337337
}
338338
}
339339

340+
if v, ok := req.FrontendAttrs["build-arg:BUILDKIT_BUILDINFO"]; ok && v != "" {
341+
if _, ok := req.ExporterAttrs["buildinfo"]; !ok {
342+
if req.ExporterAttrs == nil {
343+
req.ExporterAttrs = make(map[string]string)
344+
}
345+
req.ExporterAttrs["buildinfo"] = v
346+
}
347+
}
348+
340349
if req.Exporter != "" {
341350
exp, err := w.Exporter(req.Exporter, c.opt.SessionManager)
342351
if err != nil {

docs/deprecated.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ With the introduction of [provenance attestations](./attestations/slsa-provenanc
4444
in [BuildKit v0.11.0](https://github.com/moby/buildkit/releases/tag/v0.11.0),
4545
the build information feature has been deprecated and will be removed in the
4646
next release.
47+
48+
To completely disable the build information feature, set the build-arg
49+
`BUILDKIT_BUILDINFO=false`.

frontend/dockerfile/docs/reference.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,21 +2213,22 @@ RUN echo "I'm building for $TARGETPLATFORM"
22132213

22142214
### BuildKit built-in build args
22152215

2216-
| Arg | Type | Description |
2217-
|---------------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2218-
| `BUILDKIT_CACHE_MOUNT_NS` | String | Set optional cache ID namespace. |
2219-
| `BUILDKIT_CONTEXT_KEEP_GIT_DIR` | Bool | Trigger git context to keep the `.git` directory. |
2220-
| `BUILDKIT_INLINE_BUILDINFO_ATTRS`[^2] | Bool | Inline build info attributes in image config or not. |
2221-
| `BUILDKIT_INLINE_CACHE`[^2] | Bool | Inline cache metadata to image config or not. |
2222-
| `BUILDKIT_MULTI_PLATFORM` | Bool | Opt into determnistic output regardless of multi-platform output or not. |
2223-
| `BUILDKIT_SANDBOX_HOSTNAME` | String | Set the hostname (default `buildkitsandbox`) |
2224-
| `BUILDKIT_SYNTAX` | String | Set frontend image |
2225-
| `SOURCE_DATE_EPOCH` | Int | Set the UNIX timestamp for created image and layers. More info from [reproducible builds](https://reproducible-builds.org/docs/source-date-epoch/). Supported since Dockerfile 1.5, BuildKit 0.11 |
2216+
| Arg | Type | Description |
2217+
|---------------------------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2218+
| `BUILDKIT_CACHE_MOUNT_NS` | String | Set optional cache ID namespace. |
2219+
| `BUILDKIT_CONTEXT_KEEP_GIT_DIR` | Bool | Trigger git context to keep the `.git` directory. |
2220+
| `BUILDKIT_BUILDINFO` | Bool | Enable build info (default `true`). |
2221+
| `BUILDKIT_INLINE_BUILDINFO_ATTRS`[^2] | Bool | Inline build info attributes in image config or not. |
2222+
| `BUILDKIT_INLINE_CACHE`[^2] | Bool | Inline cache metadata to image config or not. |
2223+
| `BUILDKIT_MULTI_PLATFORM` | Bool | Opt into determnistic output regardless of multi-platform output or not. |
2224+
| `BUILDKIT_SANDBOX_HOSTNAME` | String | Set the hostname (default `buildkitsandbox`) |
2225+
| `BUILDKIT_SYNTAX` | String | Set frontend image |
2226+
| `SOURCE_DATE_EPOCH` | Int | Set the UNIX timestamp for created image and layers. More info from [reproducible builds](https://reproducible-builds.org/docs/source-date-epoch/). Supported since Dockerfile 1.5, BuildKit 0.11 |
22262227

22272228
> **Warning**
22282229
>
2229-
> Build information along `BUILDKIT_INLINE_BUILDINFO_ATTRS` build arg are
2230-
> deprecated and will be removed in the next release. See the [BuildKit Deprecated features page](https://github.com/moby/buildkit/blob/master/docs/deprecated.md)
2230+
> Build information along `BUILDKIT_BUILDINFO` and `BUILDKIT_INLINE_BUILDINFO_ATTRS`
2231+
> build args are deprecated and will be removed in the next release. See the [BuildKit Deprecated features page](https://github.com/moby/buildkit/blob/master/docs/deprecated.md)
22312232
> for status and alternative recommendation about this feature.
22322233
22332234
#### Example: keep `.git` dir

util/buildinfo/buildinfo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ func filterAttrs(key string, attrs map[string]*string) map[string]*string {
419419
var knownControlArgs = []string{
420420
"BUILDKIT_CACHE_MOUNT_NS",
421421
"BUILDKIT_CONTEXT_KEEP_GIT_DIR",
422+
"BUILDKIT_BUILDINFO",
422423
"BUILDKIT_INLINE_BUILDINFO_ATTRS",
423424
"BUILDKIT_INLINE_CACHE",
424425
"BUILDKIT_MULTI_PLATFORM",

0 commit comments

Comments
 (0)