From e0848c402362d05f0d36a3e6b13c016fcd63fc8e Mon Sep 17 00:00:00 2001
From: Teake Nutma <t.a.nutma@rug.nl>
Date: Wed, 29 Jun 2022 16:36:34 +0200
Subject: [PATCH] Pass registry and tag to dockerfiles with --build-arg

---
 .gitlab-ci.yml                       |  2 ++
 dockerfiles/latex-builder/Dockerfile | 13 +++----------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 499b238..8875166 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -41,6 +41,8 @@ build_containers:
                 --context "${CI_PROJECT_DIR}/${DOCKER_DIR}" \
                 --dockerfile "${CI_PROJECT_DIR}/${DOCKER_DIR}/Dockerfile" \
                 --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}" \
+                --build-arg "CI_AWE_IMAGE_BASE=${CI_AWE_IMAGE_BASE}" \
+                --build-arg "CI_AWE_IMAGE_TAG=${CI_COMMIT_REF_SLUG}" \
                 --cleanup
           fi
       done
diff --git a/dockerfiles/latex-builder/Dockerfile b/dockerfiles/latex-builder/Dockerfile
index 6d0e7bc..562b523 100644
--- a/dockerfiles/latex-builder/Dockerfile
+++ b/dockerfiles/latex-builder/Dockerfile
@@ -1,13 +1,6 @@
-# We use CI_COMMIT_REF_SLUG as a tag here (and not CI_AWE_IMAGE_TAG)
-# because the latter refers to what the projects that include the
-# CI templates shoud use. That variable usually points to `v5` or similar
-# and the associated tag is not always available in the Docker registry
-# at the time of building this image.
-# CI_COMMIT_REF_SLUG however should be available at build time because
-# that's what used in this project's .gitlab-ci.yml. The only time that
-# tag is not available is when building this image for a MR pipeline
-# where conda-builder is not changed and thus not built.
-FROM ${CI_AWE_IMAGE_BASE}/conda-builder:${CI_COMMIT_REF_SLUG}
+ARG CI_AWE_IMAGE_BASE
+ARG CI_AWE_IMAGE_TAG
+FROM ${CI_AWE_IMAGE_BASE}/conda-builder:${CI_AWE_IMAGE_TAG}
 
 LABEL version="1.2"
 LABEL description="Image for building LaTeX documentation through tectonic"
-- 
GitLab