This action uses Kaniko 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.
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.
|
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 |
Full path including the filename where the image tar file should be saved. This option allows saving the built image as a tarball. |
|
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. |
|
String |
No |
Registry mirror(s) to use for loading images. Formatted as a CSV list, so you can pass multiple registries. |
|
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'. |
|
String |
No |
The verbosity of logging when running the Kaniko build. It can be one of: |
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
This code is made available under the MIT license.
-
Learn more about using actions in CloudBees workflows.
-
Learn about the CloudBees platform.