From 65a6f0596677f24a799dc79a5850e3b002c40830 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Tue, 1 Dec 2020 17:40:35 +0000
Subject: [PATCH] Now also dynamically configure singularity definition for
 consistency

---
 .gitlab-ci.yml                                 |  5 ++---
 containers/release/configure_release.sh        |  5 +++++
 containers/release/eic-unstable.def            | 18 ------------------
 .../release/{eic-latest.def => eic.def.in}     |  2 +-
 4 files changed, 8 insertions(+), 22 deletions(-)
 delete mode 100644 containers/release/eic-unstable.def
 rename containers/release/{eic-latest.def => eic.def.in} (87%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a5b9b1eba..106ea10d3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,10 +21,8 @@ default:
     - |
       if [ -f .ci-env/release ]; then 
         export BRANCH='release'
-        export SINGULARITY_DEF='eic-latest.def'
       elif [ -f .ci-env/develop ]; then
         export BRANCH='develop'
-        export SINGULARITY_DEF='eic-unstable.def'
       else export BRANCH='UNKNOWN'
       fi
     - |
@@ -91,6 +89,7 @@ builder:
     - cd containers/builder
     - head Dockerfile
     - make login
+    - echo "Creating builder image for ${BUILDER_TARGET}"
     - make ${BUILDER_TARGET}
 
 config:stable:
@@ -142,7 +141,7 @@ release:singularity:
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH != "develop"'
       when: manual
   script:
-     - cp containers/release/${SINGULARITY_DEF} eic.def
+     - cp config/eic.def eic.def
      - /bin/bash .gitlabci/setup.sh
      - /bin/bash .gitlabci/build.sh eic.def
      - mkdir -p build 
diff --git a/containers/release/configure_release.sh b/containers/release/configure_release.sh
index 8af0a6899..0354ac430 100644
--- a/containers/release/configure_release.sh
+++ b/containers/release/configure_release.sh
@@ -24,3 +24,8 @@ grep export config/spack-env.sh | \
 sed '/^@ENV@/r config/eic-env.sh' containers/release/Dockerfile.in | \
   sed '/^@ENV@/d' | \
   sed "s/@TAG@/$TAG/" > config/Dockerfile
+
+## And release singularity definition
+sed '/^@ENV@/r config/eic-env.sh' containers/release/eic.def.in | \
+  sed '/^@ENV@/d' | \
+  sed "s/@TAG@/$TAG/" > config/eic.def
diff --git a/containers/release/eic-unstable.def b/containers/release/eic-unstable.def
deleted file mode 100644
index 640502c5e..000000000
--- a/containers/release/eic-unstable.def
+++ /dev/null
@@ -1,18 +0,0 @@
-Bootstrap: docker
-From: eicweb.phy.anl.gov:4567/containers/eic_container/eic:unstable
-
-%help
-  EIC software container.
-  Tools:
-     - eic_shell   : Bash shell in this container
-     - root        : Root shell in the container
-     - ipython     : Python shell in the container
-
-%labels
-  Maintainer "Whitney Armstrong, Sylvester Joosten"
-  Version v2.x
-
-%post -c /bin/bash
-  echo "  -------------------------------------------------"
-  echo "  ===> Image setup complete"
-  echo "  -------------------------------------------------"
diff --git a/containers/release/eic-latest.def b/containers/release/eic.def.in
similarity index 87%
rename from containers/release/eic-latest.def
rename to containers/release/eic.def.in
index 5ac8dd286..5f1f5b182 100644
--- a/containers/release/eic-latest.def
+++ b/containers/release/eic.def.in
@@ -1,5 +1,5 @@
 Bootstrap: docker
-From: eicweb.phy.anl.gov:4567/containers/eic_container/eic:latest
+From: eicweb.phy.anl.gov:4567/containers/eic_container/eic:@TAG@
 
 %help
   EIC software container.
-- 
GitLab