This repository has been archived on 2024-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
woodpecker-bot 5b97227384
🎉 Release 1.0.0 (#10)
This PR was opened by the
[ready-release-go](https://github.com/woodpecker-ci/plugin-ready-release-go)
plugin. When you're ready to do a release, you can merge this
pull-request and a new release with version `1.0.0` will be created
automatically. If you're not ready to do a release yet, that's fine,
whenever you add more changes to `main` this pull-request will be
updated.

## Options

- [ ] Mark this version as a release candidate

##
[1.0.0](https://github.com/woodpecker-ci/plugin-kaniko/releases/tag/1.0.0)
- 2024-01-12

### 💥 Breaking changes

- Add `dry-run` setting and docs.md
[[#12](https://github.com/woodpecker-ci/plugin-kaniko/pull/12)]
- Switch to Woodpecker Environment Variables
[[#9](https://github.com/woodpecker-ci/plugin-kaniko/pull/9)]

### Misc

- chore(deps): update alpine docker tag to v3.19
[[#11](https://github.com/woodpecker-ci/plugin-kaniko/pull/11)]
2024-01-12 23:13:24 +01:00
.woodpecker Fix release pipeline (#7) 2024-01-12 22:39:38 +01:00
.ecrc Add editorconfig and fix issues 2024-01-12 21:29:49 +01:00
.editorconfig Add editorconfig and fix issues 2024-01-12 21:29:49 +01:00
.gitignore Init pipeline (#3) 2024-01-12 22:13:24 +01:00
.pre-commit-config.yaml Init pipeline (#3) 2024-01-12 22:13:24 +01:00
.yamllint.yaml Init pipeline (#3) 2024-01-12 22:13:24 +01:00
CHANGELOG.md 🎉 Release 1.0.0 (#10) 2024-01-12 23:13:24 +01:00
Dockerfile Add support for docker hub mirrors and update image version (#1) 2024-01-12 21:23:42 +01:00
Dockerfile.test chore(deps): update alpine docker tag to v3.19 (#11) 2024-01-12 22:47:55 +01:00
docs.md Add dry-run setting and docs.mf (#12) 2024-01-12 23:12:06 +01:00
LICENSE Initial commit 2018-11-21 07:39:41 +01:00
plugin.sh Add dry-run setting and docs.mf (#12) 2024-01-12 23:12:06 +01:00
README.md Init pipeline (#3) 2024-01-12 22:13:24 +01:00
renovate.json chore: Configure Renovate (#2) 2024-01-12 22:07:21 +01:00

drone-kaniko

A thin shim-wrapper around the official Google Kaniko Docker image to make it behave like the Drone Docker plugin.

Example .drone.yml for Drone 1.0 (pushing to Docker Hub):

kind: pipeline
name: default

steps:
- name: publish
  image: banzaicloud/drone-kaniko
  settings:
    registry: registry.example.com # if not provided index.docker.io is supposed
    repo: registry.example.com/example-project
    tags: ${DRONE_COMMIT_SHA}
    cache: true
    skip_tls_verify: false # set to true for testing registries ONLY with self-signed certs
    build_args:
    - COMMIT_SHA=${DRONE_COMMIT_SHA}
    - COMMIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
    username:
      from_secret: docker-username
    password:
      from_secret: docker-password

Pushing to GCR:

kind: pipeline
name: default

steps:
- name: publish
  image: banzaicloud/drone-kaniko
  settings:
    registry: gcr.io
    repo: example.com/example-project
    tags: ${DRONE_COMMIT_SHA}
    cache: true
    json_key:
      from_secret: google-application-credentials

Use .tags file for tagging

Similarily to official drone-docker plugin you can use .tags file to embed some custom logic for creating tags for an image.

kind: pipeline
name: default

steps:
- name: build
  image: golang
  commands:
      - 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
    username:
      from_secret: docker-username
    password:
      from_secret: docker-password

Auto tag

Set auto_tag: true.

kind: pipeline
name: default

steps:
- name: build
  image: golang
  commands:
      - go get
      - go build
- name: publish
  image: banzaicloud/drone-kaniko
  settings:
    registry: registry.example.com
    repo: registry.example.com/example-project
    auto_tag: true # higher priority then .tags file
    # tags: ${DRONE_COMMIT_SHA} <= it must be left undefined to use auto_tag
    username:
      from_secret: docker-username
    password:
      from_secret: docker-password

Test that it can build

docker run -it --rm -w /src -v $PWD:/src -e PLUGIN_USERNAME=${DOCKER_USERNAME} -e PLUGIN_PASSWORD=${DOCKER_PASSWORD} -e PLUGIN_REPO=banzaicloud/drone-kaniko-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test banzaicloud/drone-kaniko

Test that caching works

Start a Docker registry at 127.0.0.1:5000:

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:

+    --cache=true \
+    --cache-repo=127.0.0.1:5000/${PLUGIN_REPO} \
docker build -t banzaicloud/drone-kaniko .

Warm up the alpine image to the cache:

docker run -v $PWD:/cache gcr.io/kaniko-project/warmer:latest --verbosity=debug --image=alpine:3.8

Run the builder (on the host network to be able to access the registry, if any specified) with mounting the local disk cache, this example pushes to Docker Hub:

docker run --net=host -it --rm -w /src -v $PWD:/cache -v $PWD:/src -e PLUGIN_USERNAME=${DOCKER_USERNAME} -e PLUGIN_PASSWORD=${DOCKER_PASSWORD} -e PLUGIN_REPO=banzaicloud/drone-kaniko-test -e PLUGIN_TAGS=test -e PLUGIN_DOCKERFILE=Dockerfile.test -e PLUGIN_CACHE=true banzaicloud/drone-kaniko

The very same example just pushing to GCR instead of Docker Hub:

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