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 0afa620e2c..c5105e5248 100644 --- a/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md +++ b/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md @@ -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 < 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 ) diff --git a/go.sum b/go.sum index 334f8f05b2..21006819ab 100644 --- a/go.sum +++ b/go.sum @@ -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=