diff --git a/.gitignore b/.gitignore index b08db0e..f276527 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +# kaniko base image cache files +sha256:* diff --git a/Dockerfile.test b/Dockerfile.test index 201b146..094f1e7 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -2,4 +2,4 @@ FROM alpine:3.8 RUN apk add --update git -ENTRYPOINT [ "/usr/bin/plugin.sh" ] +RUN apk add --update jq diff --git a/README.md b/README.md index f09134e..cf3a7d8 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,36 @@ A thin shim-wrapper around the official [Google Kaniko](https://cloud.google.com ```bash 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 ``` + +## 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 +```