From b17059b07f3e748e38e0fbae714f33200f1e2e78 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sat, 6 Nov 2021 16:57:28 +0200
Subject: [PATCH] Seperate stages for regular and base images.

Some images are base images for other images. There's a need to build
the base images first.
---
 .gitlab-ci.yml    | 31 +++++++++++++++++++++++++------
 webdav/Dockerfile |  3 ++-
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 72f6d36..a72788f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,12 +7,29 @@ include:
   - project: shore/ci-stuff
     file: templates/containerfiles.yml
 
+# Base image templates:
+stages:
+  - build-base
+  - deploy-base
+  - build
+  - deploy
+
+.container-build-base:
+  extends: .container-build
+  stage: build-base
+
+.container-push-base:
+  extends: .container-push
+  stage: deploy-base
+
 # cgit image:
 
 build-cgit:
   extends: .container-build
   variables:
     CONTEXT: cgit
+  needs:
+    - job: push-httpd
 
 push-cgit:
   extends: .container-push
@@ -26,12 +43,12 @@ push-cgit:
 # httpd latest image:
 
 build-httpd:
-  extends: .container-build
+  extends: .container-build-base
   variables:
     CONTEXT: httpd/buster
 
 push-httpd:
-  extends: .container-push
+  extends: .container-push-base
   variables:
     CONTEXT: httpd/buster
     IMAGE: httpd
@@ -42,7 +59,7 @@ push-httpd:
 # httpd buster image:
 
 push-httpd-buster:
-  extends: .container-push
+  extends: .container-push-base
   variables:
     CONTEXT: httpd/buster
     IMAGE: httpd
@@ -54,7 +71,7 @@ push-httpd-buster:
 # httpd bullseye image:
 
 build-httpd-bullseye:
-  extends: .container-build
+  extends: .container-build-base
   variables:
     CONTEXT: httpd/bullseye
 
@@ -88,12 +105,12 @@ push-sshd:
 # crond image:
 
 build-crond:
-  extends: .container-build
+  extends: .container-build-base
   variables:
     CONTEXT: crond
 
 push-crond:
-  extends: .container-push
+  extends: .container-push-base
   variables:
     CONTEXT: crond
     IMAGE: cron
@@ -123,6 +140,8 @@ build-webdav:
   extends: .container-build
   variables:
     CONTEXT: webdav
+  needs:
+    - job: push-httpd
 
 push-webdav:
   extends: .container-push
diff --git a/webdav/Dockerfile b/webdav/Dockerfile
index 22c5fe7..14172b6 100644
--- a/webdav/Dockerfile
+++ b/webdav/Dockerfile
@@ -1,4 +1,5 @@
-FROM registry.shore.co.il/httpd:bullseye
+# hadolint ignore=DL3006
+FROM registry.shore.co.il/httpd
 USER root
 RUN a2enmod dav && \
     a2enmod dav_fs && \
-- 
GitLab