vendor: github.com/moby/buildkit 28ce478b1fde

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-01-12 17:42:49 +01:00
parent 519eafaf2d
commit 9fe31e95f6
5 changed files with 82 additions and 14 deletions

View File

@ -12,7 +12,10 @@ note some configuration is only good for edge cases, please take care of it
carefully. carefully.
```toml ```toml
# debug enables additional debug logging
debug = true debug = true
# trace enables additional trace logging (very verbose, with potential performance impacts)
trace = true
# root is where all buildkit state is stored. # root is where all buildkit state is stored.
root = "/var/lib/buildkit" root = "/var/lib/buildkit"
# insecure-entitlements allows insecure entitlements, disabled by default. # insecure-entitlements allows insecure entitlements, disabled by default.

View File

@ -188,11 +188,22 @@ The following parser directives are supported:
<a name="external-implementation-features"><!-- included for deep-links to old section --></a> <a name="external-implementation-features"><!-- included for deep-links to old section --></a>
This feature is only available when using the [BuildKit](https://docs.docker.com/build/buildkit/) Use the `syntax` parser directive to declare the Dockerfile syntax version to
backend, and is ignored when using the classic builder backend. use for the build. If unspecified, BuildKit uses a bundled version of the
Dockerfile frontend. Declaring a syntax version lets you automatically use the
latest Dockerfile version without having to upgrade BuildKit or Docker Engine,
or even use a custom Dockerfile implementation.
See [Custom Dockerfile syntax](https://docs.docker.com/build/buildkit/dockerfile-frontend/) Most users will want to set this parser directive to `docker/dockerfile:1`,
page for more information. which causes BuildKit to pull the latest stable version of the Dockerfile
syntax before the build.
```dockerfile
# syntax=docker/dockerfile:1
```
For more information about how the parser directive works, see
[Custom Dockerfile syntax](https://docs.docker.com/build/buildkit/dockerfile-frontend/).
### escape ### escape
@ -346,6 +357,20 @@ directive in your Dockerfile:
string=foobarbaz echo ${string%%b*} # foo string=foobarbaz echo ${string%%b*} # foo
``` ```
- `${variable/pattern/replacement}` replace the first occurrence of `pattern`
in `variable` with `replacement`
```bash
string=foobarbaz echo ${string/ba/fo} # fooforbaz
```
- `${variable//pattern/replacement}` replaces all occurrences of `pattern`
in `variable` with `replacement`
```bash
string=foobarbaz echo ${string//ba/fo} # fooforfoz
```
In all cases, `word` can be any string, including additional environment In all cases, `word` can be any string, including additional environment
variables. variables.
@ -589,7 +614,7 @@ RUN apt-get update
RUN apt-get install -y curl RUN apt-get install -y curl
``` ```
You can specify `CMD` instructions using You can specify `RUN` instructions using
[shell or exec forms](#shell-and-exec-form): [shell or exec forms](#shell-and-exec-form):
- `RUN ["executable","param1","param2"]` (exec form) - `RUN ["executable","param1","param2"]` (exec form)
@ -2651,25 +2676,62 @@ FILE2
### Example: Creating inline files ### Example: Creating inline files
In `COPY` commands source parameters can be replaced with here-doc indicators. With `COPY` instructions, you can replace the source parameter with a here-doc
indicator to write the contents of the here-document directly to a file. The
following example creates a `greeting.txt` file containing `hello world` using
a `COPY` instruction.
```dockerfile
# syntax=docker/dockerfile:1
FROM alpine
COPY <<EOF greeting.txt
hello world
EOF
```
Regular here-doc [variable expansion and tab stripping rules](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04) apply. Regular here-doc [variable expansion and tab stripping rules](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04) apply.
The following example shows a small Dockerfile that creates a `hello.sh` script
file using a `COPY` instruction with a here-document.
```dockerfile ```dockerfile
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM alpine FROM alpine
ARG FOO=bar ARG FOO=bar
COPY <<-EOT /app/foo COPY <<-EOT /script.sh
hello ${FOO} echo "hello ${FOO}"
EOT EOT
ENTRYPOINT ash /script.sh
``` ```
In this case, file script prints "hello bar", because the variable is expanded
when the `COPY` instruction gets executed.
```console
$ docker build -t heredoc .
$ docker run heredoc
hello bar
```
If instead you were to quote any part of the here-document word `EOT`, the
variable would not be expanded at build-time.
```dockerfile ```dockerfile
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM alpine FROM alpine
COPY <<-"EOT" /app/script.sh ARG FOO=bar
echo hello ${FOO} COPY <<-"EOT" /script.sh
echo "hello ${FOO}"
EOT EOT
RUN FOO=abc ash /app/script.sh ENTRYPOINT ash /script.sh
```
Note that `ARG FOO=bar` is excessive here, and can be removed. The variable
gets interpreted at runtime, when the script is invoked:
```console
$ docker build -t heredoc .
$ docker run -e FOO=world heredoc
hello world
``` ```
## Dockerfile examples ## Dockerfile examples

View File

@ -1,6 +1,6 @@
# github.com/moby/moby v24.0.5+incompatible # github.com/moby/moby v24.0.5+incompatible
# github.com/moby/buildkit v0.13.0-beta1.0.20231219135447-957cb50df991 # github.com/moby/buildkit v0.13.0-beta1.0.20240116143623-28ce478b1fde
# github.com/docker/buildx v0.12.1 # github.com/docker/buildx v0.12.1
# github.com/docker/scout-cli v1.2.0 # github.com/docker/scout-cli v1.2.0
# github.com/docker/cli v25.0.0-rc.1+incompatible # github.com/docker/cli v25.0.0-rc.1+incompatible
# github.com/docker/compose/v2 v2.24.0 # github.com/docker/compose/v2 v2.24.0

3
go.mod
View File

@ -9,8 +9,9 @@ require (
github.com/docker/cli v25.0.0-rc.1+incompatible // indirect github.com/docker/cli v25.0.0-rc.1+incompatible // indirect
github.com/docker/compose/v2 v2.24.0 // indirect github.com/docker/compose/v2 v2.24.0 // indirect
github.com/docker/scout-cli v1.2.0 // indirect github.com/docker/scout-cli v1.2.0 // indirect
github.com/moby/buildkit v0.13.0-beta1.0.20231219135447-957cb50df991 // indirect github.com/moby/buildkit v0.13.0-beta1.0.20240116143623-28ce478b1fde // indirect
github.com/moby/moby v24.0.5+incompatible // indirect github.com/moby/moby v24.0.5+incompatible // indirect
github.com/moby/moby v24.0.8-0.20240109122856-854ca341c0f6+incompatible // indirect
) )
// buildkit depends on cli v25 beta1, pin to v24 // buildkit depends on cli v25 beta1, pin to v24

2
go.sum
View File

@ -163,6 +163,8 @@ github.com/moby/buildkit v0.13.0-beta1.0.20231214000015-a960fe501f00 h1:Ymp+x/hs
github.com/moby/buildkit v0.13.0-beta1.0.20231214000015-a960fe501f00/go.mod h1:6MddWPSL5jxy+W8eMMHWDOfZzzRRKWXPZqajw72YHBc= github.com/moby/buildkit v0.13.0-beta1.0.20231214000015-a960fe501f00/go.mod h1:6MddWPSL5jxy+W8eMMHWDOfZzzRRKWXPZqajw72YHBc=
github.com/moby/buildkit v0.13.0-beta1.0.20231219135447-957cb50df991 h1:r80LLQ91uOLxU1ElAvrB1o8oBsph51lPzVnr7t2b200= github.com/moby/buildkit v0.13.0-beta1.0.20231219135447-957cb50df991 h1:r80LLQ91uOLxU1ElAvrB1o8oBsph51lPzVnr7t2b200=
github.com/moby/buildkit v0.13.0-beta1.0.20231219135447-957cb50df991/go.mod h1:6MddWPSL5jxy+W8eMMHWDOfZzzRRKWXPZqajw72YHBc= github.com/moby/buildkit v0.13.0-beta1.0.20231219135447-957cb50df991/go.mod h1:6MddWPSL5jxy+W8eMMHWDOfZzzRRKWXPZqajw72YHBc=
github.com/moby/buildkit v0.13.0-beta1.0.20240116143623-28ce478b1fde h1:t6dpbzyD4GYAX3zlm0s0+uH8xxx2UqF9uW9zuFIr+vg=
github.com/moby/buildkit v0.13.0-beta1.0.20240116143623-28ce478b1fde/go.mod h1:NK6kY+05bXjxhEmtGEMAwvSJ19gagBukPz6N4FFzlNs=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= 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 h1:yH+5dRHH1x3XRKzl1THA2aGTy6CHYnkt5N924ADMax8=
github.com/moby/moby v24.0.2+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= github.com/moby/moby v24.0.2+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc=