Drone plugin for building and publishing Docker images using kaniko + personal patches
Go to file
2022-01-20 00:41:45 +05:30
.github Working kaniko publish to docker 2020-11-16 23:41:59 +05:30
cmd Make plugins/kaniko behave the same as plugins/kaniko-{ecr,gcr} by prefixing the registry to the repo (#31) 2022-01-20 00:41:45 +05:30
docker updated kaniko executer version to 1.6.0 to solve the docker registry authentication issues (#28) 2021-10-12 16:39:32 +05:30
pkg Make json key optional for GCR push (#30) 2021-10-18 17:06:53 +05:30
scripts Fix ecr publish 2020-12-02 15:17:28 +05:30
.drone.yml Updated go version for security fixes (#29) 2021-10-12 16:38:58 +05:30
.gitignore Add ECR policy management support (#26) 2021-09-08 15:19:52 +05:30
go.mod Add support for automatic tagging (:1, :1.2, :1.2.3, etc) for semantic versions (#22) 2021-10-18 00:05:18 +05:30
go.sum Add support for automatic tagging (:1, :1.2, :1.2.3, etc) for semantic versions (#22) 2021-10-18 00:05:18 +05:30
kaniko_test.go Add support for automatic tagging (:1, :1.2, :1.2.3, etc) for semantic versions (#22) 2021-10-18 00:05:18 +05:30
kaniko.go Add support for custom platform (#32) 2021-12-01 17:10:28 +05:30
LICENSE Initial kaniko docker 2020-11-16 23:07:13 +05:30
README.md Add support for automatic tagging (:1, :1.2, :1.2.3, etc) for semantic versions (#22) 2021-10-18 00:05:18 +05:30

drone-kaniko

Drone kaniko plugin uses kaniko to build and publish Docker images to a container registry.

Build

Build the binaries with the following commands:

export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on

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

Docker

Build the Docker images with the following commands:

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) \
  --file docker/docker/Dockerfile.linux.amd64 --tag plugins/kaniko .

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) \
  --file docker/gcr/Dockerfile.linux.amd64 --tag plugins/kaniko-gcr .

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) \
  --file docker/ecr/Dockerfile.linux.amd64 --tag plugins/kaniko-ecr .

Usage

docker run --rm \
    -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 \
    plugins/kaniko:linux-amd64

Automatic Tagging

With auto tagging enabled, semantic versions can be passed to PLUGIN_TAGS directly for expansion:

docker run --rm \
    -e PLUGIN_TAGS=v1.2.3,latest \
    -e PLUGIN_AUTO_TAG=true \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64

would both be equivalent to

PLUGIN_TAGS=1,1.2,1.2.3,latest

This allows for passing $DRONE_TAG directly as a tag for repos that use semver tags.

To avoid confusion between repo tags and image tags, PLUGIN_AUTO_TAG also recognizes a semantic version without the v prefix. As such, the following is also equivalent to the above:

docker run --rm \
    -e PLUGIN_TAGS=1.2.3,latest \
    -e PLUGIN_AUTO_TAG=true \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64