This build template builds source into a container image using Google's
kaniko doesn't depend on a Docker daemon and executes each command within a Dockerfile completely in userspace. This enables building container images in environments that can't easily or securely run a Docker daemon, such as a standard Kubernetes cluster.
kaniko is meant to be run as an image,
makes it a perfect tool to be part of a Knative build.
Create the template
kubectl apply -f https://raw.githubusercontent.com/knative/build-templates/master/kaniko/kaniko.yaml
- IMAGE: The Docker image name to apply to the newly built image. (required)
- DOCKERFILE: The path to the
Dockerfileto execute (default:
kaniko builds an image and pushes it to the destination defined as a parameter.
In order to properly authenticate to the remote container registry, the build
needs to have the proper credentials. This is achieved using a build
For an example on how to create such a
ServiceAccount to push an image to
Docker hub, see the
Build manifest and use the
template section to refer to the kaniko
build template. Set the value of the parameters such as the destination Docker
image. Note the use of the
serviceAccountName to push the image to a remote
apiVersion: build.knative.dev/v1alpha1 kind: Build metadata: name: kaniko-build spec: serviceAccountName: build-bot source: git: url: https://github.com/my-user/my-repo revision: master template: name: kaniko arguments: - name: IMAGE value: us.gcr.io/my-project/my-app
In this example, the Git repo being built is expected to have a
the root of the repository.