From 0bffdf3af829ddd9db9190bc2725b6dadc9b1bed Mon Sep 17 00:00:00 2001
From: Lucas Brandstaetter <lucas@brandstaetter.tech>
Date: Sun, 29 Sep 2024 23:45:26 +0200
Subject: [PATCH] Update build_image to per build

This change is to ensure that the image is built for each build, rather than
using the latest tag. This is to ensure that there are not race conditions
when multiple builds are running at the same time.
---
 .gitlab-ci.yml | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ca1074305..2a7978404 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -111,7 +111,7 @@ meta_build:
   variables:
     PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
   script:
-    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/.meta/Dockerfile --destination $CI_REGISTRY_IMAGE/build_image:latest $KANIKO_ARGS $KANIKO_CACHE_ARGS
+    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/.meta/Dockerfile --destination $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID $KANIKO_ARGS $KANIKO_CACHE_ARGS
   rules:
     - when: always
 
@@ -119,7 +119,7 @@ app_version:
   extends:
     - .default-rules
     - .django_runner_settings
-  image: $CI_REGISTRY_IMAGE/build_image:latest
+  image: $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID
   stage: test
   needs:
     - meta_build
@@ -137,7 +137,7 @@ app_version:
     - when: always
 
 code_style:
-  image: $CI_REGISTRY_IMAGE/build_image:latest
+  image: $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID
   stage: test
   needs:
     - meta_build
@@ -149,7 +149,7 @@ code_style:
     - when: always
 
 ruff:
-  image: $CI_REGISTRY_IMAGE/build_image:latest
+  image: $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID
   stage: test
   needs:
     - meta_build
@@ -161,7 +161,7 @@ ruff:
     - when: always
 
 ruff_format:
-  image: $CI_REGISTRY_IMAGE/build_image:latest
+  image: $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID
   stage: test
   needs:
     - meta_build
@@ -176,7 +176,7 @@ migration_check:
   extends:
     - .default-rules
     - .django_runner_settings
-  image: $CI_REGISTRY_IMAGE/build_image:latest
+  image: $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID
   stage: test
   needs:
     - meta_build
@@ -194,7 +194,7 @@ sanity_check:
   extends:
     - .default-rules
     - .django_runner_settings
-  image: $CI_REGISTRY_IMAGE/build_image:latest
+  image: $CI_REGISTRY_IMAGE/build_image:$CI_PIPELINE_ID
   stage: test
   needs:
     - meta_build
-- 
GitLab