drone-docker-buildx
Drone plugin to build and publish multiarch Docker images with buildx.
The tags follow the major version of Docker, e.g. 20
, and the minor and patch parts reflect the version
of the plugin. A full example would be 20.12.5
. Minor versions can introduce breaking changes, while patch versions can be considered non-breaking.
Be aware that the this plugin requires privileged capabilities, otherwise the integrated Docker daemon is not able to start.
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/drone-docker-buildx:23
privileged: true
settings:
username: octocat
password: secure
repo: octocat/example
tags: latest
-
Additional
host:ip
mapping.Default: none -
Generate tag names automatically based on git branch and git tag. When this feature is enabled and the event type is
tag
, the plugin will automatically tag the image using the standard semVer convention. For example:1.0.0
produces docker tags1
,1.0
,1.0.0
1.0.0-rc.1
produces docker tags1.0.0-rc.1
When the event type ispush
and the target branch is your default branch, the plugin will automatically tag the image aslatest
. All other event types and branches are ignored.
Default: false -
Generate tag names with the given suffix.Default: none
-
Allows the docker daemon to bride IP address.Default: none
-
Ccustom build arguments to pass to the build.Default: none
-
Forward environment variables as custom arguments to the build.Default: none
-
Content of the docker buildkit toml config. Example:
- name: Build image: thegeeklab/drone-docker-buildx:23 settings: repo: example/repo buildkit_config: | [registry."registry.local:30081"] http = true insecure = true
Default: false -
Images to consider as cache sources. To properly work, commas used in the cache source entries need to be escaped:
- name: Build image: thegeeklab/drone-docker-buildx:23 settings: repo: example/repo cache_from: # using quotes double-escaping is required - "type=registry\\\\,ref=example" - 'type=foo\\,ref=bar'
Default: none -
Cache destination for the build cache.Default: none
-
Enable compression of the build context using gzip.Default: false
-
Content of the docker daemon json config.Default: none
-
Set the path of the build context to use.Default: .
-
Custom docker daemon DNS server.Default: none
-
Custom docker daemon DNS search domain.Default: none
-
Disable the startup of the docker daemon.Default: false
-
Enable verbose debug mode for the docker daemon.Default: false
-
Set dockerfile to use for the image build.Default: Dockerfile
-
Disable docker push.Default: none
-
E-Mail address for authentication with the registry.Default: none
-
Enable docker daemon experimental mode.Default: false
-
Set additional tags to be used for the image. Additional tags can also be loaded from an
.extratags
file. This function can be used to push images to multiple registries at once. Therefore, it is necessary to use theconfig
flag to provide a configuration file that contains the authentication information for all used registries.Default: none -
Enable the usage of insecure registries.Default: false
-
Enable docker daemon IPv6 support.Default: false
-
Labels to add to the image.Default: none
-
Use a registry mirror to pull images.Default: none
-
A docker daemon custom MTU.Default: none
-
Set additional named build contexts (e.g., name=path).Default: none
-
Disable the usage of cached intermediate containers.Default: false
-
Default: false
-
Password for authentication with the registry.Default: none
-
Target platforms for build.Default: none
-
Generate provenance attestation for the build (shorthand for
--attest=type=provenance
).Default: none -
Enforce to pull the base image at build time.Default: true
-
Enable suppression of the build output.Default: false
-
Docker registry to upload images.Default: https://index.docker.io/v1/
-
Repository name for the image. If the image is to be pushed to registries other than the default DockerHub, it is necessary to set
repo
as fully-qualified name.Default: none -
Generate sbom attestation for the build (shorthand for
--attest type=sbom
).Default: none -
The docker daemon storage driver.Default: none
-
The docker daemon storage path.Default: /var/lib/docker
-
Set repository tags to use for the image. Tags can also be loaded from a
.tags
file.Default: latest -
The docker build target.Default: none
-
Username for authentication with the registry.Default: none
If the created image is to be pushed to registries other than the default DockerHub, it is necessary to set registry
and repo
as fully-qualified name.
GHCR:
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/drone-docker-buildx:23
privileged: true
settings:
registry: ghcr.io
username: octocat
password: secret-access-token
repo: ghcr.io/octocat/example
tags: latest
AWS ECR:
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/drone-docker-buildx:23
privileged: true
environment:
AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id
AWS_SECRET_ACCESS_KEY:
from_secret: aws_secret_access_key
settings:
registry: <account_id>.dkr.ecr.<region>.amazonaws.com
repo: <account_id>.dkr.ecr.<region>.amazonaws.com/octocat/example
tags: latest
Build the binary with the following command:
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
make build
Build the Docker image with the following command:
docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-docker-buildx .
docker run --rm \
-e PLUGIN_TAG=latest \
-e PLUGIN_REPO=octocat/hello-world \
-e DRONE_COMMIT_SHA=00000000 \
-v $(pwd):$(pwd) \
-w $(pwd) \
--privileged \
thegeeklab/drone-docker-buildx --dry-run