Giter Site home page Giter Site logo

drone-kaniko's Introduction

drone-kaniko

Drone kaniko plugin uses kaniko to build and publish Docker images to a container registry.

Plugin images are published with 1.6.0 as well as 1.8.1 kaniko version from 1.5.1 release tag. plugins/kaniko:<release-tag> uses 1.6.0 version while plugins/kaniko:<release-tag>-kaniko1.8.1 uses 1.8.1 version. Similar convention is used for plugins/kaniko-ecr & plugins/kaniko-gcr images as well.

Build

Build the binaries with the following commands:

export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on

go build -v -a -tags netgo -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
go build -v -a -tags netgo -o release/linux/amd64/kaniko-gcr ./cmd/kaniko-gcr
go build -v -a -tags netgo -o release/linux/amd64/kaniko-ecr ./cmd/kaniko-ecr
go build -v -a -tags netgo -o release/linux/amd64/kaniko-acr ./cmd/kaniko-acr

Docker

Build the Docker images with the following commands:

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/docker/Dockerfile.linux.amd64 --tag plugins/kaniko .
  
docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/acr/Dockerfile.linux.amd64 --tag plugins/kaniko-acr .

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/gcr/Dockerfile.linux.amd64 --tag plugins/kaniko-gcr .

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/ecr/Dockerfile.linux.amd64 --tag plugins/kaniko-ecr .

Usage

Manual Tagging

docker run --rm \
    -e PLUGIN_TAGS=1.2,latest \
    -e PLUGIN_DOCKERFILE=/drone/Dockerfile \
    -e PLUGIN_REPO=foo/bar \
    -e PLUGIN_USERNAME=foo \
    -e PLUGIN_PASSWORD=bar \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64

With expanded tagging enabled, semantic versions can be passed to PLUGIN_TAGS directly for expansion.

Note: this feature only works for build labels. Artifact labels are not supported.

docker run --rm \
    -e PLUGIN_TAGS=v1.2.3,latest \
    -e PLUGIN_EXPAND_TAG=true \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64

would both be equivalent to

PLUGIN_TAGS=1,1.2,1.2.3,latest

This allows for passing $DRONE_TAG directly as a tag for repos that use semver tags.

To avoid confusion between repo tags and image tags, PLUGIN_EXPAND_TAG also recognizes a semantic version without the v prefix. As such, the following is also equivalent to the above:

docker run --rm \
    -e PLUGIN_TAGS=1.2.3,latest \
    -e PLUGIN_EXPAND_TAG=true \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64

Auto Tagging

The auto tag feature of docker plugin is also supported.

When auto tagging is enabled, if any of the case is matched below, a docker build will be pushed with auto generated tags. Otherwise the docker build will be skipped.

Note: this feature only works for build labels. Artifact labels are not supported.

Git Tag Push:

docker run --rm \
    -e DRONE_COMMIT_REF=refs/tags/v1.2.3 \
    -e PLUGIN_REPO=foo/bar \
    -e PLUGIN_USERNAME=foo \
    -e PLUGIN_PASSWORD=bar \
    -e PLUGIN_AUTO_TAG=true \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64

Tags to push:

  • 1.2.3
  • 1.2
  • 1

Git Commit Push in default branch:

docker run --rm \
    -e DRONE_COMMIT_REF=refs/heads/master \
    -e DRONE_REPO_BRANCH=main \
    -e PLUGIN_REPO=foo/bar \
    -e PLUGIN_USERNAME=foo \
    -e PLUGIN_PASSWORD=bar \
    -e PLUGIN_AUTO_TAG=true \
    -v $(pwd):/drone \
    -w /drone \
    plugins/kaniko:linux-amd64

Tags to push:

  • latest

drone-kaniko's People

Contributors

shubham149 avatar aman-harness avatar jamie-harness avatar colinhoglund avatar bradrydzewski avatar zzl221000 avatar 15cm avatar kylelemons avatar ymage avatar fishy avatar geribatai avatar raghavharness avatar pnovotnak avatar michaelboke avatar hcsaustrup avatar beniamin avatar aradisavljevic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.