gcr.io/kaniko-project/executor:debug
with some extra scripts that are used in our pipelines. It’s better to have the scripts in an image, which is used in a pipeline than having the scripts themselves encapsulated in a yaml, because yaml is not very fit for that, and the scripts are than nearly impossible to debug.
The entrypoint of the image is /script.sh
. This will look for
- a Dockerfile in the current directory
- or if not present in Dockerfiles in subdirectories (non-recursively).
- every Dockerfile is build and pushed to the registry (default registry.npohosting.nl)
The name of the artifact can be influenced by environment variables, but on default
it is based on the ARG NAME in the Dockerfile itself.
We mainly use this in maven-projects. Which might have 1 or more submodules that produce wars that are encapsulated in a docker-image with tomcat.
An advantage of this approach is that it can be used locally. Sometimes it is just good to know how to deploy without gitlab itself. It debugs easier, and I needed it also when our account ran out of minutes.
michiel@mitulo:(pomst)(main,80)~/npo/media/main/media-server$ ~/github/npo-poms/kaniko/kaniko.sh
2 docker build setup
38 defining os_app_name
60 defining get_docker_image_name
kaniko build setup
Defining function setup_kaniko
Defining function kaniko_execute
Using build args
Copying /root/.docker/config-gitlab.json to /kaniko/.docker/config.json
lines: 24 /root/.docker/config-gitlab.json
Version no specified, taking 8.3-SNAPSHOT
Missing IMAGE variable. Trying to find now by calling get_actifact_versions
Using image artifact: "registry.npohosting.nl/poms/media:dev" (tag: "dev", internal: "/poms/media:dev", full: "poms/media:dev")
Building and pushing image: "registry.npohosting.nl/poms/media:dev" (), (project) version: 8.3-SNAPSHOT
INFO[0000] Retrieving image manifest ghcr.io/vpro/tomcat:10.19
INFO[0000] Retrieving image ghcr.io/vpro/tomcat:10.19 from registry ghcr.io
INFO[0001] Built cross stage deps: map[]
INFO[0001] Retrieving image manifest ghcr.io/vpro/tomcat:10.19
INFO[0001] Returning cached image manifest
INFO[0001] Executing 16 build triggers
INFO[0001] Building stage 'ghcr.io/vpro/tomcat:10.19' [idx: '0', base-idx: '-1']
INFO[0001] Unpacking rootfs as cmd ADD target/*${PROJECT_VERSION}.war /tmp/app.war requires it.
Script to run in a directory with a maven `pom.xml` a `target/*.war` and a `Dockerfile`.
The war can be used in the Dockerfile, the version of the image will be taken from the `pom.xml`. The result will build and be pushed to the registry with kaniko (in docker)
It will pick up needed settings with credentials from several spots in your home dir. Where you may have them using
oc get secret ... > ~/.kube/config.gitlab