MonkeyCI plugin for building container images using Kaniko. You can include this plugin in your MonkeyCI build scripts in order to create container images, either for a single platform or for multiple platforms.
First include the plugin in your build deps.edn
:
{:deps {com.monkeyci/plugin-kaniko {:mvn/version "VERSION"}}}
Several functions are available that generate build jobs depending on your needs. If you only need to build a simple image for a single architecture, you can do this:
(require '[monkey.ci.plugin.kaniko :as pk])
;; Returns a job function that can be executed by MonkeyCI
(pk/image-job {:target-img "docker.io/target/img:tag"
:arch :amd
:subdir "docker"
:dockerfile "Dockerfile"
:creds-param "docker-credentials"
:job-id "build-img"})
The creds-param
config key is used to fetch the credentials from your build parameters.
By default this is docker-credentials
. The credentials should be of the format of your
standard .docker/config.json
. dockerfile
is relative to your repository root directory,
and so is subdir
, which is used as the context for building the image. The default name
for the docker file is Dockerfile
.
The architectures that can be specified are those that are available in MonkeyCI (e.g.
:arm
, :amd
).
You can pass any additional container options using :container-opts
. This is useful
if you want to specify dependencies or change the default memory allocation for the
containers.
Usually you will want to build multi platform images. In Kaniko this is not possible, but
you can create and push multiple images, each for one platform, and them merge them
together using manifest-tool. This tool will
push a manifest that contains the information of all platform-specific images. This library
provides functions that create build jobs that allow you to build and push a multi-platform
image this way. Use multi-platform-image-job
for this.
;; This will generate multiple jobs that can be included in your build process.
(pk/multi-platform-image
{:target-img "docker.io/target/img:tag"
:archs [:arm :amd]})
This function will generate one image
job for each platform, that will build and push
an image to <target-img>-<arch>
. An extra job is added to invoke manifest-tool
that will
push a manifest that groups all image together using target-img
. You can override the job
ids by specifying the :image {:job-id}
and :manifest {:job-id}
respectively.
Additional build parameters are the same as those for image
and image-job
(except for arch
).
Make configuration more flexible by allowing to specify the image templates and other stuff.
Copyright (c) 2024 by Monkey Projects
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close