diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5c3fcbb4ec6cf03126f710f0a2375cfa7d1130b2..f76dd45ff0659359ef74675f307aa9247243b756 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,7 +12,8 @@ variables:
   DATA_PORT: "2060"
   DATA_TYPE: "edge"
   UPSTREAM_PATH: ghsc/geomag/geomag-algorithms
-
+  BRANCH_OR_TAG: :${CI_COMMIT_REF_SLUG} # format looks like ':feature-branch'
+  BRANCH_OR_TAG: ${BRANCH_OR_TAG/:master/:latest} #replaces ':master' with ':latest'
 # Do not run in upstream for merge requests
 workflow:
   rules:
@@ -25,10 +26,8 @@ workflow:
 
 .adjust_image_names:
   before_script:
-    - IMAGE_NAME=${APP_NAME}:${CI_COMMIT_REF_SLUG}
-    - IMAGE_NAME=${IMAGE_NAME/:master/:latest}
-    - PROJECT_IMAGE_NAME=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
-    - PROJECT_IMAGE_NAME=${PROJECT_IMAGE_NAME/:master/:latest}
+    - IMAGE_NAME=${APP_NAME}${BRANCH_OR_TAG}
+    - PROJECT_IMAGE_NAME=${CI_REGISTRY_IMAGE}${BRANCH_OR_TAG}
 
 .deploy:
   extends:
@@ -41,8 +40,8 @@ workflow:
       /container-deploy/deploy.sh
       scripts/.
     - export APP_NAME=${APP_NAME}
-    - export IMAGE_NAME=${IMAGE_NAME}
-    - export REGISTRY=${CI_REGISTRY_IMAGE}
+    - export IMAGE_TAG=${BRANCH_OR_TAG} 
+    - export REGISTRY_IMAGE=${CI_REGISTRY_IMAGE}
     - export STACK_NAME=${APP_NAME}
     - ./scripts/deploy.sh
   stage: deploy
diff --git a/scripts/custom.funcs.sh b/scripts/custom.funcs.sh
index e6a75db4625ef407a17fb24cc824a33995a9b034..7890960a5e7b644bcb1f457d986f5b91c731d87b 100644
--- a/scripts/custom.funcs.sh
+++ b/scripts/custom.funcs.sh
@@ -84,7 +84,7 @@ services:
   # custom.funcs.sh and the custom.config.sh as well. Probably just do not
   # ever do this...
   web:
-    image: ${REGISTRY}/${IMAGE_NAME}
+    image: ${REGISTRY_IMAGE}${IMAGE_TAG}
     deploy:
       restart_policy:
         condition: any