diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9a393a648def0e6f6c42e800dc903c59b06ec16b..42c8b156169cbb65fd3d0843d544d4671600c8ff 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,6 +8,9 @@ scheduler-docker-build:
   # Use the official docker image.
   image: docker:latest
   stage: build
+  only: 
+    - main
+    - tags
   variables:
     DOCKER_HOST: tcp://docker:2375
     DOCKER_DRIVER: overlay2
@@ -19,18 +22,23 @@ scheduler-docker-build:
   # Default branch leaves tag empty (= latest tag)
   # All other branches are tagged with the escaped branch name (commit ref slug)
   script:
-    - |
-      if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
-        tag=""
-        echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
-      else
-        tag=":$CI_COMMIT_REF_SLUG"
-        echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
-      fi
-  # Build frontend Docker Container
-    - mv ./scheduler/.production.env ./scheduler/.env
-    - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}/scheduler" ./scheduler
-    - docker push "$CI_REGISTRY_IMAGE${tag}/scheduler"
+  - |
+    if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
+      tag="latest"
+      echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
+    elif [[ -n "$CI_COMMIT_TAG" ]]; then
+      tag="$CI_COMMIT_TAG"
+      echo "Running on tag '$CI_COMMIT_TAG': tag = $tag"
+    else
+      tag="$CI_COMMIT_REF_SLUG"
+      echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
+    fi
+    image_name="$CI_REGISTRY_IMAGE/scheduler:$tag"
+    echo "Docker image name is: $image_name"
+  - mv ./scheduler/.production.env ./scheduler/.env
+  - docker build --pull -t "$image_name" ./src
+  - docker push "$image_name"
+
 
 deploy:
   stage: deploy