diff --git a/_vendor/github.com/docker/buildx/docs/bake-reference.md b/_vendor/github.com/docker/buildx/docs/bake-reference.md index fd0ee7e1fd9e..19483210a5be 100644 --- a/_vendor/github.com/docker/buildx/docs/bake-reference.md +++ b/_vendor/github.com/docker/buildx/docs/bake-reference.md @@ -359,6 +359,21 @@ target "app" { } ``` +### `target.call` + +Specifies the frontend method to use. Frontend methods let you, for example, +execute build checks only, instead of running a build. This is the same as the +`--call` flag. + +```hcl +target "app" { + call = "check" +} +``` + +For more information about frontend methods, refer to the CLI reference for +[`docker buildx build --call`](https://docs.docker.com/reference/cli/docker/buildx/build/#call). + ### `target.context` Specifies the location of the build context to use for this target. diff --git a/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md b/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md index 507751da256b..a5749ca533cc 100644 --- a/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md +++ b/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md @@ -192,11 +192,6 @@ following lines are all treated identically: # dIrEcTiVe=value ``` -The following parser directives are supported: - -- `syntax` -- `escape` - ### syntax @@ -2221,7 +2216,8 @@ Keep the following things in mind about volumes in the Dockerfile. - a drive other than `C:` - **Changing the volume from within the Dockerfile**: If any build steps change the - data within the volume after it has been declared, those changes will be discarded. + data within the volume after it has been declared, those changes will be discarded + when using the legacy builder. When using Buildkit, the changes will instead be kept. - **JSON formatting**: The list is parsed as a JSON array. You must enclose words with double quotes (`"`) rather than single quotes (`'`). diff --git a/_vendor/modules.txt b/_vendor/modules.txt index b6cd83719227..aaf838f5fdd0 100644 --- a/_vendor/modules.txt +++ b/_vendor/modules.txt @@ -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 diff --git a/content/guides/compose-bake/index.md b/content/guides/compose-bake/index.md index b5ded0fce0a5..c6f4d312366c 100644 --- a/content/guides/compose-bake/index.md +++ b/content/guides/compose-bake/index.md @@ -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": "" } } } diff --git a/content/manuals/build/bake/overrides.md b/content/manuals/build/bake/overrides.md index 2028650f16af..c4fc5bb2a77c 100644 --- a/content/manuals/build/bake/overrides.md +++ b/content/manuals/build/bake/overrides.md @@ -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" } } } diff --git a/content/manuals/build/bake/variables.md b/content/manuals/build/bake/variables.md index b584cc1483a2..0db49d53718d 100644 --- a/content/manuals/build/bake/variables.md +++ b/content/manuals/build/bake/variables.md @@ -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, diff --git a/content/manuals/build/buildkit/dockerfile-release-notes.md b/content/manuals/build/buildkit/dockerfile-release-notes.md index 7505071da589..e05d4751de97 100644 --- a/content/manuals/build/buildkit/dockerfile-release-notes.md +++ b/content/manuals/build/buildkit/dockerfile-release-notes.md @@ -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" >}} diff --git a/content/manuals/build/release-notes.md b/content/manuals/build/release-notes.md index 80afc400a16c..9e27b9f79b1b 100644 --- a/content/manuals/build/release-notes.md +++ b/content/manuals/build/release-notes.md @@ -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=` 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) diff --git a/go.mod b/go.mod index 7c3f3bd6b11f..491345ccc8ef 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 381ab3775f34..9fcba6476bfb 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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=