drone-kaniko/README.md

43 lines
1.5 KiB
Markdown
Raw Normal View History

2018-11-21 14:45:09 +00:00
# kaniko-plugin
A thin shim-wrapper around the official [Google Kaniko](https://cloud.google.com/blog/products/gcp/introducing-kaniko-build-container-images-in-kubernetes-and-google-container-builder-even-without-root-access) Docker image to make it behave like the [Drone Docker plugin](http://plugins.drone.io/drone-plugins/drone-docker/).
2018-11-24 16:29:40 +00:00
## Test that it can build
2018-11-21 14:45:09 +00:00
```bash
2018-11-24 16:29:40 +00:00
docker run -it --rm -w /src -v $PWD:/src -e DOCKER_USERNAME=${DOCKER_USERNAME} -e DOCKER_PASSWORD=${DOCKER_PASSWORD} -e PLUGIN_REPO=banzaicloud/kaniko-plugin-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test banzaicloud/kaniko-plugin
2018-11-21 14:45:09 +00:00
```
2018-11-25 14:59:05 +00:00
## Test that caching works
Start a Docker registry at 127.0.0.1:5000:
```bash
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:
```diff
+ --cache=true \
+ --cache-repo=127.0.0.1:5000/${PLUGIN_REPO} \
```
```bash
docker build -t banzaicloud/kaniko-plugin .
```
Warm up the alpine image to the cache:
```bash
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:
```bash
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/kaniko-plugin-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test banzaicloud/kaniko-plugin
```