Skip to contentSkip to conversation

ci: use kaniko to build lavacli container

isar-cip-core Michael Adler 2 participants 2 messages Sep 1

lore
Share & tools
lore
#0 lore raw

Avoid privileged image builds and run the job on cheaper small runners. (note that large runners cannot override the Kaniko entrypoint required
by kas-isar because of a GitLab limitation).

---
 .gitlab-ci.yml | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
.gitlab-ci.yml +10 -5
index 8dbe62d..75f88e0 100644
@@ -934,13 +934,18 @@ include: '.reproducible-check-ci.yml'
 
 lavacli-container:
   stage: build
-  image: quay.io/buildah/stable:v1.41.4
+  image:
+    name: ghcr.io/osscontainertools/kaniko:v1.28.4-debug
+    entrypoint: [""]
   tags:
-    - large-rootless
+    - small
   before_script:
-    - buildah login -u $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD $CI_REGISTRY
+    - mkdir -p /kaniko/.docker
+    - umask 077; printf '{"auths":{"%s":{"username":"%s","password":"%s"}}}\n' "$CI_REGISTRY" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" > /kaniko/.docker/config.json
   script:
-    - buildah build -f scripts/Dockerfile.lavacli -t $CI_REGISTRY_IMAGE/lavacli .
-    - buildah push $CI_REGISTRY_IMAGE/lavacli
+    - /kaniko/executor
+      --context $CI_PROJECT_DIR/scripts
+      --dockerfile $CI_PROJECT_DIR/scripts/Dockerfile.lavacli
+      --destination $CI_REGISTRY_IMAGE/lavacli:latest
   rules:
     - if: '$CI_PIPELINE_SOURCE == "schedule" && $LAVACLI_CONTAINER'
Signature · 1 line
2.55.0
#1 lore raw
Quoted 3 lines · Michael Adler

Avoid privileged image builds and run the job on cheaper small runners. (note that large runners cannot override the Kaniko entrypoint required
by kas-isar because of a GitLab limitation).

Thanks for fixing this, but looking at the code...

Quoted 11 lines
---
 .gitlab-ci.yml | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
.gitlab-ci.yml +0 -0
index 8dbe62d..75f88e0 100644

.gitlab-ci.yml include: '.reproducible-check-ci.yml' · line 939

Quoted 7 lines
.gitlab-ci.yml +3 -1
@@ -934,13 +934,18 @@ include: '.reproducible-check-ci.yml'
 
 lavacli-container:
   stage: build
-  image: quay.io/buildah/stable:v1.41.4
+  image:
+    name: ghcr.io/osscontainertools/kaniko:v1.28.4-debug
+    entrypoint: [""]

...like here...

.gitlab-ci.yml include: '.reproducible-check-ci.yml' · line 944

Quoted 7 lines
.gitlab-ci.yml +3 -2
   tags:
-    - large-rootless
+    - small
   before_script:
-    - buildah login -u $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD $CI_REGISTRY
+    - mkdir -p /kaniko/.docker
+    - umask 077; printf '{"auths":{"%s":{"username":"%s","password":"%s"}}}\n' "$CI_REGISTRY" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" > /kaniko/.docker/config.json

...and here...

.gitlab-ci.yml include: '.reproducible-check-ci.yml' · line 951

Quoted 9 lines
.gitlab-ci.yml +4 -2
   script:
-    - buildah build -f scripts/Dockerfile.lavacli -t $CI_REGISTRY_IMAGE/lavacli .
-    - buildah push $CI_REGISTRY_IMAGE/lavacli
+    - /kaniko/executor
+      --context $CI_PROJECT_DIR/scripts
+      --dockerfile $CI_PROJECT_DIR/scripts/Dockerfile.lavacli
+      --destination $CI_REGISTRY_IMAGE/lavacli:latest
   rules:
     - if: '$CI_PIPELINE_SOURCE == "schedule" && $LAVACLI_CONTAINER'

...kaniko does not yet seem to be made for this use case. Does no one package or more user-friendly container for gitlab-ci?

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center