Update buildkit reference to v0.22.0-rc1

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2025-05-15 16:23:35 +02:00
parent fddfedc2b7
commit 8462d61578
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
3 changed files with 86 additions and 2 deletions

View File

@ -689,7 +689,8 @@ EOF
The available `[OPTIONS]` for the `RUN` instruction are:
| Option | Minimum Dockerfile version |
| ------------------------------- | -------------------------- |
|---------------------------------|----------------------------|
| [`--device`](#run---device) | 1.14-labs |
| [`--mount`](#run---mount) | 1.2 |
| [`--network`](#run---network) | 1.3 |
| [`--security`](#run---security) | 1.1.2-labs |
@ -707,6 +708,87 @@ guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practi
The cache for `RUN` instructions can be invalidated by [`ADD`](#add) and [`COPY`](#copy) instructions.
### RUN --device
> [!NOTE]
> Not yet available in stable syntax, use [`docker/dockerfile:1-labs`](#syntax)
> version. It also needs BuildKit 0.20.0 or later.
```dockerfile
RUN --device=name,[required]
```
`RUN --device` allows build to request [CDI devices](https://github.com/moby/buildkit/blob/master/docs/cdi.md)
to be available to the build step.
The device `name` is provided by the CDI specification registered in BuildKit.
In the following example, multiple devices are registered in the CDI
specification for the `vendor1.com/device` vendor.
```yaml
cdiVersion: "0.6.0"
kind: "vendor1.com/device"
devices:
- name: foo
containerEdits:
env:
- FOO=injected
- name: bar
annotations:
org.mobyproject.buildkit.device.class: class1
containerEdits:
env:
- BAR=injected
- name: baz
annotations:
org.mobyproject.buildkit.device.class: class1
containerEdits:
env:
- BAZ=injected
- name: qux
annotations:
org.mobyproject.buildkit.device.class: class2
containerEdits:
env:
- QUX=injected
```
The device name format is flexible and accepts various patterns to support
multiple device configurations:
* `vendor1.com/device`: request the first device found for this vendor
* `vendor1.com/device=foo`: request a specific device
* `vendor1.com/device=*`: request all devices for this vendor
* `class1`: request devices by `org.mobyproject.buildkit.device.class` annotation
#### Example: CUDA-Powered LLaMA Inference
In this example we use the `--device` flag to run `llama.cpp` inference using
an NVIDIA GPU device through CDI:
```dockerfile
# syntax=docker/dockerfile:1-labs
FROM scratch AS model
ADD https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf /model.gguf
FROM scratch AS prompt
COPY <<EOF prompt.txt
Q: Generate a list of 10 unique biggest countries by population in JSON with their estimated poulation in 1900 and 2024. Answer only newline formatted JSON with keys "country", "population_1900", "population_2024" with 10 items.
A:
[
{
EOF
FROM ghcr.io/ggml-org/llama.cpp:full-cuda-b5124
RUN --device=nvidia.com/gpu=all \
--mount=from=model,target=/models \
--mount=from=prompt,target=/tmp \
./llama-cli -m /models/model.gguf -no-cnv -ngl 99 -f /tmp/prompt.txt
```
### RUN --mount
```dockerfile

2
go.mod
View File

@ -16,6 +16,6 @@ replace (
github.com/docker/cli => github.com/docker/cli v28.1.0-rc.2+incompatible
github.com/docker/compose/v2 => github.com/docker/compose/v2 v2.36.0
github.com/docker/scout-cli => github.com/docker/scout-cli v1.15.0
github.com/moby/buildkit => github.com/moby/buildkit v0.20.0
github.com/moby/buildkit => github.com/moby/buildkit v0.22.0-rc1
github.com/moby/moby => github.com/moby/moby v28.1.0-rc.2+incompatible
)

2
go.sum
View File

@ -372,6 +372,8 @@ github.com/moby/buildkit v0.19.0 h1:w9G1p7sArvCGNkpWstAqJfRQTXBKukMyMK1bsah1HNo=
github.com/moby/buildkit v0.19.0/go.mod h1:WiHBFTgWV8eB1AmPxIWsAlKjUACAwm3X/14xOV4VWew=
github.com/moby/buildkit v0.20.0 h1:aF5RujjQ310Pn6SLL/wQYIrSsPXy0sQ5KvWifwq1h8Y=
github.com/moby/buildkit v0.20.0/go.mod h1:HYFUIK+iGDRxRgdphZ9Nv0y1Fz7mv0HrU7xZoXx217E=
github.com/moby/buildkit v0.22.0-rc1 h1:Q47jZZws7+0WhucTcm35NRV8NcO6n1SwIikzfqcGKLo=
github.com/moby/buildkit v0.22.0-rc1/go.mod h1:j4pP5hxiTWcz7xuTK2cyxQislHl/N2WWHzOy43DlLJw=
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=