You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82
Original file line number
Diff line number
Diff line change
@@ -344,6 +344,88 @@ If set to true, docker compose will build with the `--with-dependencies` option
344
344
345
345
The default is `false`.
346
346
347
+
#### `builder` (object)
348
+
349
+
Defines the properties required for creating, using and removing Builder Instances. If not set, the default Builder Instance on the Agent Instance will be used.
350
+
351
+
##### `bootstrap` (boolean)
352
+
353
+
If set to true, will boot builder instance after creation. Optional when using `create`.
354
+
355
+
The default is `true`.
356
+
357
+
##### `create` (boolean)
358
+
359
+
If set to true, will use `docker buildx create` to create a new Builder Instance using the propeties defined. If a Builder Instance with the same `name` already exists, it will not be recreated.
360
+
361
+
The default is `false`.
362
+
363
+
##### `debug` (boolean)
364
+
365
+
If set to true, enables debug logging during creation of builder instance. Optional when using `create`.
366
+
367
+
The default is `false`.
368
+
369
+
##### `driver`
370
+
371
+
If set will create a Builder Instance using the selected Driver and use it. Available Drivers:
372
+
373
+
-`docker-container` creates a dedicated BuildKit container using Docker.
374
+
-`kubernetes` creates BuildKit pods in a Kubernetes cluster.
375
+
-`remote` connects directly to a manually managed BuildKit daemon.
376
+
377
+
More details on different [Build Drivers](https://docs.docker.com/build/builders/drivers/).
378
+
379
+
##### `driver-opt`
380
+
381
+
Commas separated, Key-Value pairs of driver-specific options to configure the Builder Instance when using `create`. Available options for each Driver:
If set to true, will keep the BuildKit daemon running after the buildx context (Builder) is removed. This is useful when you manage BuildKit daemons and buildx contexts independently. Only supported by the `docker-container` and `kubernetes` drivers. Optional when using `remove`.
392
+
393
+
The default is `false`.
394
+
395
+
##### `keep-state` (boolean)
396
+
397
+
If set to true, will keep BuildKit state so it can be reused by a new Builder with the same name, persisting the driver's cache. Currently, only supported by the `docker-container` driver. Optional when using `remove`.
398
+
399
+
The default is `false`.
400
+
401
+
##### `name`
402
+
403
+
Sets the name of the Builder instance to create or use. Required when using `create` or `use` builder paramaters.
404
+
405
+
##### `platform`
406
+
407
+
Commas separated, fixed platforms for builder instance. Optional when using `create`.
408
+
409
+
Example: `linux/amd64,linux/arm64`
410
+
411
+
##### `remote-address`
412
+
413
+
Address of remote builder instance. Required when using `driver: remote`.
414
+
415
+
Example: `tcp://localhost:1234`
416
+
417
+
##### `remove` (boolean)
418
+
419
+
If set to true will stop and remove the Builder Instance specified by `name`.
420
+
421
+
The default is `false`.
422
+
423
+
##### `use` (boolean)
424
+
425
+
If set to true will use Builder Instance specified by `name`.
Copy file name to clipboardExpand all lines: docs/examples.md
+113-2
Original file line number
Diff line number
Diff line change
@@ -271,7 +271,7 @@ A newly spawned agent won't contain any of the docker caches for the first run w
271
271
272
272
```yaml
273
273
steps:
274
-
- label: ":docker Build an image"
274
+
- label: ":docker: Build an image"
275
275
plugins:
276
276
- docker-compose#v5.4.1:
277
277
build: app
@@ -295,7 +295,7 @@ The values you add in the `cache-from` will be mapped to the corresponding servi
295
295
296
296
```yaml
297
297
steps:
298
-
- label: ":docker Build an image"
298
+
- label: ":docker: Build an image"
299
299
plugins:
300
300
- docker-compose#v5.4.1:
301
301
build: app
@@ -312,3 +312,114 @@ steps:
312
312
push:
313
313
- app:myregistry:port/myrepo/myapp:latest
314
314
```
315
+
316
+
### Create, Use and Remove Builder Instances
317
+
318
+
#### Create
319
+
320
+
Most Docker setups, unless configured, will use the `docker` Builder Driver by default. More details on it [here](https://docs.docker.com/build/builders/drivers/docker/).
321
+
322
+
The `docker` driver can handle most situations but for advance features with the Docker, different Builder Drivers are required and this requires a Builder Instance being created first, which can be done manually or with the Plugin. To create a Builder Instance using a chosen Driver, requires the `name`, `driver` and `create` parameters:
323
+
324
+
```yaml
325
+
steps:
326
+
- label: ":docker: Build an image"
327
+
plugins:
328
+
- docker-compose#v5.4.1:
329
+
build: app
330
+
push: app:index.docker.io/myorg/myrepo:my-branch
331
+
cache-from:
332
+
- "app:myregistry:port/myrepo/myapp:my-branch"
333
+
- "app:myregistry:port/myrepo/myapp:latest"
334
+
builder:
335
+
name: container
336
+
driver: docker-container
337
+
create: true
338
+
```
339
+
340
+
**If a Builder Instance with the same `name` already exists, it will not be recreated.**
341
+
342
+
#### Use
343
+
344
+
By default, Builder Instances specified by `name` or that are created with `create` are not used, and the default Builder Instance on the Agent will be used. To use a Builder Instance, requires the `name` and `use` parameters and the Builder Instance to exist:
345
+
346
+
```yaml
347
+
steps:
348
+
- label: ":docker: Build an image"
349
+
plugins:
350
+
- docker-compose#v5.4.1:
351
+
build: app
352
+
push: app:index.docker.io/myorg/myrepo:my-branch
353
+
cache-from:
354
+
- "app:myregistry:port/myrepo/myapp:my-branch"
355
+
- "app:myregistry:port/myrepo/myapp:latest"
356
+
builder:
357
+
name: container
358
+
use: true
359
+
```
360
+
361
+
#### Remove
362
+
363
+
By default, Builder Instances specified by `name` or that are created with `create` are not removed after the Job finishs. To remove a Builder Instance, requires the `name` and `remove` parameters and the Builder Instance to exist:
364
+
365
+
```yaml
366
+
steps:
367
+
- label: ":docker: Build an image"
368
+
plugins:
369
+
- docker-compose#v5.4.1:
370
+
build: app
371
+
push: app:index.docker.io/myorg/myrepo:my-branch
372
+
cache-from:
373
+
- "app:myregistry:port/myrepo/myapp:my-branch"
374
+
- "app:myregistry:port/myrepo/myapp:latest"
375
+
builder:
376
+
name: container
377
+
driver: docker-container
378
+
create: true
379
+
use: true
380
+
remove: true
381
+
```
382
+
383
+
**Removing a Builder Instance by default will remove the daemon running it and its state (which can be used for cache).**
384
+
**To keep the daemon or state, use the `keep-daemon` or `keep-state` parameters.**
385
+
**These parameter are only applicable with specific Drivers, for detail see [`docker buildx rm`](https://docs.docker.com/reference/cli/docker/buildx/rm/).**
386
+
387
+
### Reusing caches from remote registries
388
+
389
+
A newly spawned agent won't contain any of the docker caches for the first run which will result in a long build step. To mitigate this you can reuse caches from a remote registry, but requires pushing cache and manifests to a registry using a Builder Driver that supports cache exports e.g., `docker-container` - the `docker` driver does not support this by default. For any remote registry used that requires authenication, see [Authenticated registries](#authenticated-registries) for more details. This requires use of the `cache-from`, `cache-to`, `name` and `use` parameters but will use the `create` and `driver` parameters to create the Builder Instance across multiple Agents:
The first Step will build the Image using a Builder Instance with the `docker-container` driver and push the image cache to the remote registry, as specified by `cache-to`, with additional cache export options being used to export all the layers of intermediate steps with the image manifests. More details cache export options [here](https://github.com/moby/buildkit?tab=readme-ov-file#registry-push-image-and-cache-separately).
424
+
425
+
The second Step will build the Image using a Builder Instance with the `docker-container` driver and use remote registry for the image cache, as specified by `cache-from`, speeding up Image building process.
0 commit comments