Merge pull request #21143 from dvdksn/bake-escape-var-interpolation

build(bake): escape variable interpolation in bake definition
This commit is contained in:
David Karlsson 2024-10-17 12:10:40 +02:00 committed by GitHub
commit d3465452e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 0 deletions

View File

@ -78,6 +78,35 @@ $ docker buildx bake --print
}
```
## Escape variable interpolation
If you want to bypass variable interpolation when parsing the Bake definition,
use double dollar signs (`$${VARIABLE}`).
```hcl
target "default" {
dockerfile-inline = <<EOF
FROM alpine
ARG TARGETARCH
RUN echo "Building for $${TARGETARCH/amd64/x64}"
EOF
platforms = ["linux/amd64", "linux/arm64"]
}
```
```console
$ docker buildx bake --progress=plain
...
#8 [linux/arm64 2/2] RUN echo "Building for arm64"
#8 0.036 Building for arm64
#8 DONE 0.0s
#9 [linux/amd64 2/2] RUN echo "Building for x64"
#9 0.046 Building for x64
#9 DONE 0.1s
...
```
## Using variables in variables across files
When multiple files are specified, one file can use variables defined in