kaliko updated

This commit is contained in:
2022-11-26 15:28:56 +03:00
parent ca7005705e
commit a8e2bd89ce
3 changed files with 22 additions and 10 deletions

View File

@@ -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 HOME /root
ENV USER 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 ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json
# add the wrapper which acts as a drone plugin # 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" ] ENTRYPOINT [ "/kaniko/plugin.sh" ]

View File

@@ -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/). 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 ```yaml
kind: pipeline kind: pipeline
@@ -46,10 +46,6 @@ steps:
## Use `.tags` file for tagging ## 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 ```yaml
kind: pipeline kind: pipeline
name: default name: default
@@ -61,12 +57,18 @@ steps:
- go get - go get
- go build - go build
- make versiontags > .tags - make versiontags > .tags
- name: publish - name: publish
image: banzaicloud/drone-kaniko image: banzaicloud/drone-kaniko
settings: settings:
registry: registry.example.com registry: registry.example.com
repo: registry.example.com/example-project 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: username:
from_secret: docker-username from_secret: docker-username
password: password:
@@ -144,3 +146,11 @@ The very same example just pushing to GCR instead of Docker Hub:
```bash ```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 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 .
```

View File

@@ -7,6 +7,7 @@ export PATH=$PATH:/kaniko/
REGISTRY=${PLUGIN_REGISTRY:-index.docker.io} REGISTRY=${PLUGIN_REGISTRY:-index.docker.io}
if [ "${PLUGIN_USERNAME:-}" ] || [ "${PLUGIN_PASSWORD:-}" ]; then if [ "${PLUGIN_USERNAME:-}" ] || [ "${PLUGIN_PASSWORD:-}" ]; then
DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64 | tr -d "\n"` DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64 | tr -d "\n"`
cat > /kaniko/.docker/config.json <<DOCKERJSON cat > /kaniko/.docker/config.json <<DOCKERJSON
@@ -30,6 +31,7 @@ CONTEXT=${PLUGIN_CONTEXT:-$PWD}
LOG=${PLUGIN_LOG:-info} LOG=${PLUGIN_LOG:-info}
EXTRA_OPTS="" EXTRA_OPTS=""
if [[ -n "${PLUGIN_TARGET:-}" ]]; then if [[ -n "${PLUGIN_TARGET:-}" ]]; then
TARGET="--target=${PLUGIN_TARGET}" TARGET="--target=${PLUGIN_TARGET}"
fi fi