Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions _vendor/github.com/docker/buildx/docs/bake-reference.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions _vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# github.com/moby/moby v27.3.1+incompatible
# github.com/moby/buildkit v0.17.1-0.20241031124041-354f2d13c905
# github.com/docker/buildx v0.18.0
# github.com/docker/cli v27.3.2-0.20241107125754-eb986ae71b0c+incompatible
# github.com/moby/buildkit v0.18.0
# github.com/docker/buildx v0.19.1
# github.com/docker/cli v27.4.0-rc.2+incompatible
# github.com/docker/compose/v2 v2.30.3
# github.com/docker/scout-cli v1.15.0
4 changes: 0 additions & 4 deletions content/guides/compose-bake/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,19 @@ represents a single build.
"result": {
"context": "result",
"dockerfile": "Dockerfile",
"network": ""
},
"seed": {
"context": "seed-data",
"dockerfile": "Dockerfile",
"network": ""
},
"vote": {
"context": "vote",
"dockerfile": "Dockerfile",
"target": "dev",
"network": ""
},
"worker": {
"context": "worker",
"dockerfile": "Dockerfile",
"network": ""
}
}
}
Expand Down
54 changes: 37 additions & 17 deletions content/manuals/build/bake/overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,43 +288,63 @@ which is the short commit hash generated by `git rev-parse --short HEAD`.
Overriding non-string variables with environment variables is supported. Values
passed as environment variables are coerced into suitable types first.

The following example defines a `PORT` variable with a default value of `8080`.
The `default` target uses a [ternary operator](expressions.md#ternary-operators)
to set the `PORT` variable to the value of the environment variable `PORT`
if it is greater than `1024`, otherwise it uses the default value.

In this case, the `PORT` variable is coerced to an integer before the ternary
operator is evaluated.
The following example defines a `PORT` variable. The `backend` target uses the
`PORT` variable as-is, and the `frontend` target uses the value of `PORT`
incremented by one.

```hcl
default_port = 8080

variable "PORT" {
default = default_port
default = 3000
}

target "default" {
group "default" {
targets = ["backend", "frontend"]
}

target "backend" {
args = {
PORT = PORT > 1024 ? PORT : default_port
PORT = PORT
}
}

target "frontend" {
args = {
PORT = add(PORT, 1)
}
}
```

Attempting to set the `PORT` variable with a value less than `1024` will result
in the default value being used.
Overriding `PORT` using an environment variable will first coerce the value
into the expected type, an integer, before the expression in the `frontend`
target runs.

```console
$ PORT=80 docker buildx bake --print
$ PORT=7070 docker buildx bake --print
```

```json
{
"target": {
"group": {
"default": {
"targets": [
"backend",
"frontend"
]
}
},
"target": {
"backend": {
"context": ".",
"dockerfile": "Dockerfile",
"args": {
"PORT": "7070"
}
},
"frontend": {
"context": ".",
"dockerfile": "Dockerfile",
"args": {
"PORT": "8080"
"PORT": "7071"
}
}
}
Expand Down
88 changes: 88 additions & 0 deletions content/manuals/build/bake/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,94 @@ $ docker buildx bake --print
}
```

## Validating variables

To verify that the value of a variable conforms to an expected type, value
range, or other condition, you can define custom validation rules using the
`validation` block.

In the following example, validation is used to enforce a numeric constraint on
a variable value; the `PORT` variable must be 1024 or higher.

```hcl
# Define a variable `PORT` with a default value and a validation rule
variable "PORT" {
default = 3000 # Default value assigned to `PORT`

# Validation block to ensure `PORT` is a valid number within the acceptable range
validation {
condition = PORT >= 1024 # Ensure `PORT` is at least 1024
error_message = "The variable 'PORT' must be 1024 or higher." # Error message for invalid values
}
}
```

If the `condition` expression evaluates to `false`, the variable value is
considered invalid, whereby the build invocation fails and `error_message` is
emitted. For example, if `PORT=443`, the condition evaluates to `false`, and
the error is raised.

Values are coerced into the expected type before the validation is set. This
ensures that any overrides set with environment variables work as expected.

### Validate multiple conditions

To evaluate more than one condition, define multiple `validation` blocks for
the variable. All conditions must be `true`.

Here’s an example:

```hcl
# Define a variable `VAR` with multiple validation rules
variable "VAR" {
# First validation block: Ensure the variable is not empty
validation {
condition = VAR != ""
error_message = "The variable 'VAR' must not be empty."
}

# Second validation block: Ensure the value contains only alphanumeric characters
validation {
# VAR and the regex match must be identical:
condition = VAR == regex("[a-zA-Z0-9]+", VAR)
error_message = "The variable 'VAR' can only contain letters and numbers."
}
}
```

This example enforces:

- The variable must not be empty.
- The variable must match a specific character set.

For invalid inputs like `VAR="hello@world"`, the validation would fail.

### Validating variable dependencies

You can reference other Bake variables in your condition expression, enabling
validations that enforce dependencies between variables. This ensures that
dependent variables are set correctly before proceeding.

Here’s an example:

```hcl
# Define a variable `FOO`
variable "FOO" {}

# Define a variable `BAR` with a validation rule that references `FOO`
variable "BAR" {
# Validation block to ensure `FOO` is set if `BAR` is used
validation {
condition = FOO != "" # Check if `FOO` is not an empty string
error_message = "The variable 'BAR' requires 'FOO' to be set."
}
}
```

This configuration ensures that the `BAR` variable can only be used if `FOO`
has been assigned a non-empty value. Attempting to build without setting `FOO`
will trigger the validation error.

## Escape variable interpolation

If you want to bypass variable interpolation when parsing the Bake definition,
Expand Down
15 changes: 15 additions & 0 deletions content/manuals/build/buildkit/dockerfile-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ issues, and bug fixes in [Dockerfile reference](/reference/dockerfile.md).

For usage, see the [Dockerfile frontend syntax](frontend.md) page.

## 1.12.0

{{< release-date date="2024-11-27" >}}

The full release note for this release is available
[on GitHub](https://github.com/moby/buildkit/releases/tag/dockerfile%2F1.12.0).

```dockerfile
# syntax=docker/dockerfile:1.12.0
```

- Fix incorrect description in History line of image configuration with multiple `ARG` instructions. [moby/buildkit#5508]

[moby/buildkit#5508]: https://github.com/moby/buildkit/pull/5508

## 1.11.1

{{< release-date date="2024-11-08" >}}
Expand Down
62 changes: 62 additions & 0 deletions content/manuals/build/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,70 @@ toc_max: 2
This page contains information about the new features, improvements, and bug
fixes in [Docker Buildx](https://github.com/docker/buildx).

## 0.19.1

{{< release-date date="2024-11-27" >}}

The full release note for this release is available
[on GitHub](https://github.com/docker/buildx/releases/tag/v0.19.1).

### Bug fixes

- Reverted the change in v0.19.0 that added new object notation for the fields
that previously required CSV strings in Bake definition. This enhancement was
reverted because of backwards incompatibility issues were discovered in some
edge cases. This feature has now been postponed to the v0.20.0 release.
[docker/buildx#2824](https://github.com/docker/buildx/pull/2824)

## 0.19.0

{{< release-date date="2024-11-27" >}}

The full release note for this release is available
[on GitHub](https://github.com/docker/buildx/releases/tag/v0.19.0).

### New

- Bake now requires you to allow filesystem entitlements when your build needs
to read or write files outside of your current working directory.
[docker/buildx#2796](https://github.com/docker/buildx/pull/2796),
[docker/buildx#2812](https://github.com/docker/buildx/pull/2812).

To allow filesystem entitlements, use the `--allow fs.read=<path>` flag for
the `docker buildx bake` command.

This feature currently only reports a warning when using a local Bake
definition, but will start to produce an error starting from the v0.20
release. To enable the error in the current release, you can set
`BUILDX_BAKE_ENTITLEMENTS_FS=1`.

### Enhancements

- Bake definition now supports new object notation for the fields that previously required CSV strings as inputs. [docker/buildx#2758](https://github.com/docker/buildx/pull/2758)

> [!NOTE]
> This enhancement was reverted in [v0.19.1](#0191) due to a bug.

- Bake definition now allows defining validation conditions to variables. [docker/buildx#2794](https://github.com/docker/buildx/pull/2794)
- Metadata file values can now contain JSON array values. [docker/buildx#2777](https://github.com/docker/buildx/pull/2777)
- Improved error messages when using an incorrect format for labels. [docker/buildx#2778](https://github.com/docker/buildx/pull/2778)
- FreeBSD and OpenBSD artifacts are now included in the release. [docker/buildx#2774](https://github.com/docker/buildx/pull/2774), [docker/buildx#2775](https://github.com/docker/buildx/pull/2775), [docker/buildx#2781](https://github.com/docker/buildx/pull/2781)

### Bug fixes

- Fixed an issue with printing Bake definitions containing empty Compose networks. [docker/buildx#2790](https://github.com/docker/buildx/pull/2790).

### Packaging

- Compose support has been updated to v2.4.4. [docker/buildx#2806](https://github.com/docker/buildx/pull/2806) [docker/buildx#2780](https://github.com/docker/buildx/pull/2780).

## 0.18.0

{{< release-date date="2024-10-31" >}}

The full release note for this release is available
[on GitHub](https://github.com/docker/buildx/releases/tag/v0.18.0).

### New

- The `docker buildx inspect` command now displays BuildKit daemon configuration options set with a TOML file. [docker/buildx#2684](https://github.com/docker/buildx/pull/2684)
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module github.com/docker/docs
go 1.23.1

require (
github.com/docker/buildx v0.18.0 // indirect
github.com/docker/cli v27.3.2-0.20241107125754-eb986ae71b0c+incompatible // indirect
github.com/docker/buildx v0.19.1 // indirect
github.com/docker/cli v27.4.0-rc.2+incompatible // indirect
github.com/docker/compose/v2 v2.30.3 // indirect
github.com/docker/scout-cli v1.15.0 // indirect
github.com/moby/buildkit v0.17.1-0.20241031124041-354f2d13c905 // indirect
github.com/moby/buildkit v0.18.0 // indirect
github.com/moby/moby v27.3.1+incompatible // indirect
)

replace (
github.com/docker/buildx => github.com/docker/buildx v0.18.0
github.com/docker/buildx => github.com/docker/buildx v0.19.1
github.com/docker/cli => github.com/docker/cli v27.3.2-0.20241107125754-eb986ae71b0c+incompatible
github.com/docker/compose/v2 => github.com/docker/compose/v2 v2.30.3
github.com/docker/scout-cli => github.com/docker/scout-cli v1.15.0
github.com/moby/buildkit => github.com/moby/buildkit v0.17.1-0.20241031124041-354f2d13c905
github.com/moby/buildkit => github.com/moby/buildkit v0.18.0
github.com/moby/moby => github.com/moby/moby v27.3.1+incompatible
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ github.com/docker/buildx v0.17.1 h1:9ob2jGp4+W9PxWw68GsoNFp+eYFc7eUoRL9VljLCSM4=
github.com/docker/buildx v0.17.1/go.mod h1:kJOhOhS47LRvrLFRulFiO5SE6VJf54yYMn7DzjgO5W0=
github.com/docker/buildx v0.18.0 h1:rSauXHeJt90NvtXrLK5J992Eb0UPJZs2vV3u1zTf1nE=
github.com/docker/buildx v0.18.0/go.mod h1:JGNSshOhHs5FhG3u51jXUf4lLOeD2QBIlJ2vaRB67p4=
github.com/docker/buildx v0.19.1 h1:muQEvRJLvOCS0p/67gPwjnQPWqE5ot3sGkb2Eq7vCmw=
github.com/docker/buildx v0.19.1/go.mod h1:k4WP+XmGRYL0a7l4RZAI2TqpwhuAuSQ5U/rosRgFmAA=
github.com/docker/cli v24.0.2+incompatible h1:QdqR7znue1mtkXIJ+ruQMGQhpw2JzMJLRXp6zpzF6tM=
github.com/docker/cli v24.0.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/cli v24.0.4+incompatible h1:Y3bYF9ekNTm2VFz5U/0BlMdJy73D+Y1iAAZ8l63Ydzw=
Expand Down Expand Up @@ -314,6 +316,8 @@ github.com/moby/buildkit v0.17.0 h1:ZA/4AxwBbve1f3ZaNNJQiCBtTV62R6YweWNwq4A+sTc=
github.com/moby/buildkit v0.17.0/go.mod h1:ru8NFyDHD8HbuKaLXJIjK9nr3x6FZR+IWjtF07S+wdM=
github.com/moby/buildkit v0.17.1-0.20241031124041-354f2d13c905 h1:KMEmQThIQYXKvBurcvM+6zZjxP2CoNSsF/wUpW+RC/E=
github.com/moby/buildkit v0.17.1-0.20241031124041-354f2d13c905/go.mod h1:ru8NFyDHD8HbuKaLXJIjK9nr3x6FZR+IWjtF07S+wdM=
github.com/moby/buildkit v0.18.0 h1:KSelhNINJcNA3FCWBbGCytvicjP+kjU5kZlZhkTUkVo=
github.com/moby/buildkit v0.18.0/go.mod h1:vCR5CX8NGsPTthTg681+9kdmfvkvqJBXEv71GZe5msU=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/moby v24.0.2+incompatible h1:yH+5dRHH1x3XRKzl1THA2aGTy6CHYnkt5N924ADMax8=
github.com/moby/moby v24.0.2+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc=
Expand Down
Loading