This repository has been archived on 2024-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Angus Lees ad1fd17aa5 Fix handling of long username/password
Apparently the busybox implementation of `base64` will line-wrap long output strings.
This meant that long username+password combinations could produce base64 that
contained spurious "\n" characters, which then led to:
```
2019/05/06 00:47:39 Unable to parse "/kaniko/.docker/config.json": invalid character '\n' in string literal
```

Fixed by just removing the newlines in base64 output.  A "better" solution would use a different base64
implementation that avoided line-wrapping in the first place.
2019-05-06 09:16:50 +02:00
.gitignore Add caching example 2018-11-25 15:59:05 +01:00
Dockerfile fix user name in dockerfile 2019-01-09 09:39:14 +01:00
Dockerfile.test Add caching example 2018-11-25 15:59:05 +01:00
LICENSE Initial commit 2018-11-21 07:39:41 +01:00
plugin.sh Fix handling of long username/password 2019-05-06 09:16:50 +02:00
README.md Rename to drone-kaniko 2019-01-08 11:51:32 +01:00

drone-kaniko

A thin shim-wrapper around the official Google Kaniko Docker image to make it behave like the Drone Docker plugin.

Example .drone.yml for Drone 1.0

kind: pipeline
name: default

steps:
- name: publish
  image: banzaicloud/drone-kaniko
  settings:
    registry: registry.example.com
    repo: registry.example.com/example-project
    tags: ${DRONE_COMMIT_SHA}
    cache: true
    build_args:
    - COMMIT_SHA=${DRONE_COMMIT_SHA}
    - COMMIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
    username:
      from_secret: docker-username
    password:
      from_secret: docker-password

Test that it can build

docker run -it --rm -w /src -v $PWD:/src -e PLUGIN_USERNAME=${DOCKER_USERNAME} -e PLUGIN_PASSWORD=${DOCKER_PASSWORD} -e PLUGIN_REPO=banzaicloud/drone-kaniko-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test banzaicloud/drone-kaniko

Test that caching works

Start a Docker registry at 127.0.0.1:5000:

docker run -d -p 5000:5000 --restart always --name registry --hostname registry.local registry:2

Add the following lines to plugin.sh's final command and build a new image from it:

+    --cache=true \
+    --cache-repo=127.0.0.1:5000/${PLUGIN_REPO} \
docker build -t banzaicloud/drone-kaniko .

Warm up the alpine image to the cache:

docker run -v $PWD:/cache gcr.io/kaniko-project/warmer:latest --image=alpine:3.8

Run the builder on the host network to be able to access the registry:

docker run --net=host -it --rm -w /src -v $PWD:/cache -v $PWD:/src -e DOCKER_USERNAME=${DOCKER_USERNAME} -e DOCKER_PASSWORD=${DOCKER_PASSWORD} -e PLUGIN_REPO=banzaicloud/drone-kaniko-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test banzaicloud/drone-kaniko