diff --git a/.gitignore b/.gitignore index f1c181e..b08db0e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,5 @@ *.so *.dylib -# Test binary, build with `go test -c` -*.test - # Output of the go coverage tool, specifically when used with LiteIDE *.out diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..45002b7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM gcr.io/kaniko-project/executor:v0.6.0 AS kaniko + +FROM alpine:3.8 + +# clone the official kaniko container into this one, env vars needs to be re-set +COPY --from=kaniko / / +ENV HOME /root +ENV USER /root +ENV SSL_CERT_DIR=/kaniko/ssl/certs +ENV DOCKER_CONFIG /kaniko/.docker/ +ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json + +# add the wrapper which acts as a drone plugin +COPY plugin.sh /usr/bin/ +ENTRYPOINT [ "/usr/bin/plugin.sh" ] diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..201b146 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,5 @@ +FROM alpine:3.8 + +RUN apk add --update git + +ENTRYPOINT [ "/usr/bin/plugin.sh" ] diff --git a/README.md b/README.md index 7d9d890..34b99f7 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ -# kaniko-plugin \ No newline at end of file +# 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/). + +## Test that it can build itself + +```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 -e PLUGIN_TAG=test -e PLUGIN_DOCKERFILE=Dockerfile.test banzaicloud/kaniko-plugin +``` diff --git a/plugin.sh b/plugin.sh new file mode 100755 index 0000000..c252e58 --- /dev/null +++ b/plugin.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -euo pipefail + +export PATH=$PATH:/kaniko/ + +DOCKER_AUTH=`echo -n "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" | base64` + +cat > /kaniko/.docker/config.json <