Skip to content

Latest commit

 

History

History
128 lines (96 loc) · 3.53 KB

README.adoc

File metadata and controls

128 lines (96 loc) · 3.53 KB

CloudBees action: Build and publish Docker images with Kaniko

Use this action to build and publish Docker images using Kaniko, which builds container images from a Dockerfile. Kaniko builds images inside a container or Kubernetes cluster.

Prerequisites

To authenticate with the Docker registry, you must have a Docker config file in the ${HOME}/.docker/config.json path.

Use the OCI credentials configuration action to generate a Docker config file, as in the following example.

In your YAML file, add:

      - id: dockerconfig
        name: Configure container registry credentials
        uses: cloudbees-io/configure-oci-credentials@v1
        with:
          registry: ${{ vars.DOCKER_REGISTRY }}
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

The Docker config file must be formatted in JSON, as follows:

{
	"auths": {
		"<registry host>": {
			"username": "<username>",
			"password": "<password>",
			"auth": "<username>:<password>"
		}
	}
}
Note
The "auth":"<username>:<password>" field must be base64-encoded.

Inputs

Table 1. Input details
Input name Data type Required? Description

dockerfile

String

No

The path to the Dockerfile to be built. Default is Dockerfile.

context

String

No

The path to the build context. Default is ${{ cloudbees.workspace }}.

destination

String

Yes

The target image to be published. Formatted as a CSV list, so you can pass multiple images.

tar-path

String

No

Full path including the filename where the image tar file should be saved. This option allows saving the built image as a tarball.

build-args

String

No

The build arguments to be passed to the Kaniko build. Formatted as a CSV list, so you can pass multiple build arguments.

labels

String

No

The label metadata added to the final image. Formatted as a CSV list, so you can pass multiple labels.

registry-mirrors

String

No

Registry mirror(s) to use for loading images. Formatted as a CSV list, so you can pass multiple registries.

skip-default-registry-fallback

String

No

If set, fails build if registry-mirrors cannot pull image. If registry-mirrors is empty, this flag is ignored. Accepts 'true' or 'false', default is 'false'.

verbosity

String

No

The verbosity of logging when running the Kaniko build. It can be one of: panic, fatal, error, warn, info, debug, trace. Default is info.

Usage example

In your YAML file, add:

      - name: Build a container image with Kaniko
        uses: cloudbees-io/kaniko@v1
        with:
          dockerfile: path/to/Dockerfile
          context: .
          destination: <registry host>/<image name>:1.0.1,<registry host>/<image name>:latest
          build-args: BUILDKIT_CONTEXT_KEEP_GIT_DIR=1,BUILDKIT_INLINE_CACHE=1
          labels: maintainer=John Smith,version=1.0.1
          verbosity: info
          tar-path: path/to/save/image.tar

License

This code is made available under the MIT license.

References