Use the Kaniko action to build images based upon a Dockerfile then publish the image to a Docker registry. Kaniko builds images inside a container or kubernetes cluster. This action also reports the image and tag names to the workflow run for artifact traceability purposes.
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.STAGING_DOCKER_REGISTRY }} username: ${{ secrets.STAGING_DOCKER_USERNAME }} password: ${{ secrets.STAGING_DOCKER_PASSWORD }}
The Docker config file must be formatted in JSON, as follows:
{ "auths": { "<registry host>": { "username": "<username>", "password": "<password>", "auth": "<username>:<password>" } } }
The "auth":"<username>:<password>" field must be base64-encoded.
|
All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
Input name | Data type | Required? | Description |
---|---|---|---|
|
String |
No |
The path to the Dockerfile to be built. Default is |
|
String |
No |
The path to the build context. Default is |
|
String |
Yes |
The target image to be published. Formatted as a CSV list, so you can pass multiple images. |
|
String |
No |
The build arguments to be passed to the Kaniko build. Formatted as a CSV list, so you can pass multiple build arguments. |
|
String |
No |
The label metadata added to the final image. Formatted as a CSV list, so you can pass multiple labels. |
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