2020-11-16 19:11:59 +01:00
|
|
|
# drone-kaniko
|
2020-11-16 18:37:13 +01:00
|
|
|
|
2020-11-16 19:11:59 +01:00
|
|
|
Drone kaniko plugin uses [kaniko](https://github.com/GoogleContainerTools/kaniko) to build and publish Docker images to a container registry.
|
2020-11-16 18:37:13 +01:00
|
|
|
|
|
|
|
## Build
|
|
|
|
|
|
|
|
Build the binaries with the following commands:
|
|
|
|
|
|
|
|
```console
|
|
|
|
export GOOS=linux
|
|
|
|
export GOARCH=amd64
|
|
|
|
export CGO_ENABLED=0
|
|
|
|
export GO111MODULE=on
|
|
|
|
|
2020-11-16 19:11:59 +01:00
|
|
|
go build -v -a -tags netgo -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
|
|
|
|
go build -v -a -tags netgo -o release/linux/amd64/kaniko-gcr ./cmd/kaniko-gcr
|
|
|
|
go build -v -a -tags netgo -o release/linux/amd64/kaniko-ecr ./cmd/kaniko-ecr
|
2020-11-16 18:37:13 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Docker
|
|
|
|
|
|
|
|
Build the Docker images with the following commands:
|
|
|
|
|
|
|
|
```console
|
|
|
|
docker build \
|
|
|
|
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
|
|
|
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
2020-11-26 11:59:05 +01:00
|
|
|
--file docker/docker/Dockerfile.linux.amd64 --tag plugins/kaniko .
|
2020-11-16 18:37:13 +01:00
|
|
|
|
|
|
|
docker build \
|
|
|
|
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
|
|
|
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
2020-11-16 19:11:59 +01:00
|
|
|
--file docker/gcr/Dockerfile.linux.amd64 --tag plugins/kaniko-gcr .
|
2020-11-16 18:37:13 +01:00
|
|
|
|
|
|
|
docker build \
|
|
|
|
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
|
|
|
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
2020-11-16 19:11:59 +01:00
|
|
|
--file docker/ecr/Dockerfile.linux.amd64 --tag plugins/kaniko-ecr .
|
2020-11-16 18:37:13 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```console
|
|
|
|
docker run --rm \
|
2020-11-16 20:09:21 +01:00
|
|
|
-e PLUGIN_TAGS=1.2,latest \
|
|
|
|
-e PLUGIN_DOCKERFILE=/drone/Dockerfile \
|
|
|
|
-e PLUGIN_REPO=foo/bar \
|
|
|
|
-e PLUGIN_USERNAME=foo \
|
|
|
|
-e PLUGIN_PASSWORD=bar \
|
|
|
|
-v $(pwd):/drone \
|
|
|
|
-w /drone \
|
2021-03-02 16:45:44 +01:00
|
|
|
plugins/kaniko:linux-amd64
|
2020-11-16 18:37:13 +01:00
|
|
|
```
|