From 6bf4b9f85617ff9c72ad34ab0267d49badd6b45d Mon Sep 17 00:00:00 2001
From: Lucas Brandstaetter <lucas@brandstaetter.tech>
Date: Sun, 29 Sep 2024 23:44:05 +0200
Subject: [PATCH] Add kaniko warmup

With this the kaniko will no longer pull the base image for every build,
but instead use the local cache.
---
 .gitlab-ci.yml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 85e8b2b13..ca1074305 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -53,6 +53,22 @@ default:
     SSO_SECRET_GENERATE: "True"
     STORAGE_TYPE: local
 
+# Warm up the local image cache
+# Will throw a warning for local stages, but that's fine
+warmup:
+  stage: prepare
+  image:
+    name: gcr.io/kaniko-project/executor:debug
+    entrypoint: [""]
+  cache:
+    paths:
+      - "$CI_PROJECT_DIR/.cache/kaniko"
+  script:
+    - /kaniko/warmer --cache-dir=$CI_PROJECT_DIR/.cache/kaniko -d Dockerfile
+  rules:
+    - when: always
+
+
 # Kaniko build setup
 .build:
   image:
@@ -90,6 +106,8 @@ generate_css:
 meta_build:
   stage: prepare
   extends: .build
+  needs:
+    - warmup
   variables:
     PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
   script:
-- 
GitLab