diff --git a/Dockerfile b/Dockerfile index 7579cd5..572bd93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gcr.io/kaniko-project/executor:debug-v0.19.0 +FROM gcr.io/kaniko-project/executor:v1.9.1-debug ENV HOME /root ENV USER root @@ -7,5 +7,5 @@ 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 /kaniko/plugin.sh +COPY ./plugin.sh /kaniko/plugin.sh ENTRYPOINT [ "/kaniko/plugin.sh" ] diff --git a/README.md b/README.md index f8fc7c3..d4fcc33 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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/). -Example .drone.yml for Drone 1.0 (pushing to Docker Hub): +Example .drone.yml for Drone 2.15 (pushing to Docker Hub): ```yaml kind: pipeline @@ -46,10 +46,6 @@ steps: ## Use `.tags` file for tagging -Similarily to official -[drone-docker](https://github.com/drone-plugins/drone-docker) plugin you can use -`.tags` file to embed some custom logic for creating tags for an image. - ```yaml kind: pipeline name: default @@ -61,12 +57,18 @@ steps: - go get - go build - make versiontags > .tags + - name: publish image: banzaicloud/drone-kaniko settings: registry: registry.example.com repo: registry.example.com/example-project - # tags: ${DRONE_COMMIT_SHA} <= it must be left undefined + tags: + - build-${DRONE_BUILD_NUMBER} + - latest + - latest-${DRONE_COMMIT_AUTHOR} + - latest-${DRONE_BRANCH}-${DRONE_COMMIT_AUTHOR} + - latest-${DRONE_BRANCH} username: from_secret: docker-username password: @@ -144,3 +146,11 @@ The very same example just pushing to GCR instead of Docker Hub: ```bash docker run --net=host -it --rm -w /src -v $PWD:/cache -v $PWD:/src -e PLUGIN_REGISTRY=gcr.io -e PLUGIN_REPO=paas-dev1/drone-kaniko-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test -e PLUGIN_CACHE=true -e PLUGIN_JSON_KEY="$(<$HOME/google-application-credentials.json)" banzaicloud/drone-kaniko ``` + +Build + +```bash + +docker buildx build --no-cache --platform linux/amd64 --push -t 1sept/drone-kaniko:latest -t 1sept/drone-kaniko:v1.9.1-debug . + +``` \ No newline at end of file diff --git a/plugin.sh b/plugin.sh index 31e8cd3..fe3f481 100755 --- a/plugin.sh +++ b/plugin.sh @@ -7,8 +7,9 @@ export PATH=$PATH:/kaniko/ REGISTRY=${PLUGIN_REGISTRY:-index.docker.io} if [ "${PLUGIN_USERNAME:-}" ] || [ "${PLUGIN_PASSWORD:-}" ]; then + DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64 | tr -d "\n"` - + cat > /kaniko/.docker/config.json <