diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index eb81edda0645763bb29f8524ef811a54f0b4db3d..2a70203476156d06de5e985cc082242b6960eb97 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,10 +3,18 @@ stages:
   - test
   - deploy
 
-build_gms_client:
-  stage: build
+.gms_client:
   tags:
     - docker
+  rules:
+    - if: '$CI_COMMIT_BRANCH != "master"'
+      when: never
+    - changes:
+        - gms-client/gms-client/*
+
+build_gms_client:
+  extends: .gms_client
+  stage: build
   script:
     - cd gms-client/gms-client
     - mvn clean package -DskipTests -DfinalName=gms-client
@@ -15,28 +23,66 @@ build_gms_client:
       - gms-client/gms-client/target/gms-client.jar
       - gms-client/gms-client/pom.xml
     expire_in: 7 days
-  only:
-    - master
 
 test_gms_client:
+  extends: .gms_client
+  stage: test
+  script:
+    - cd gms-client/gms-client
+    - mvn clean test
+
+test_gms:
   stage: test
   tags:
     - docker
+  image: git.ia2.inaf.it:5050/ia2/ia2-devops/maven-otj-pg-embedded
   script:
-    - cd gms-client/gms-client
+    - cd gms
     - mvn clean test
-  only:
-    - master
+    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print "coverage=" 100*covered/instructions }' target/site/jacoco/jacoco.csv
+  coverage: '/coverage=\d+\.\d+/'
+  rules:
+    - if: '$CI_COMMIT_BRANCH != "master"'
+      when: never
+    - changes:
+        - gms/*
 
 deploy_gms_client:
+  extends: .gms_client
   stage: deploy
-  tags:
-    - docker
   script:
     - mvn deploy:deploy-file
         -Dfile=gms-client/gms-client/target/gms-client.jar
         -DrepositoryId=ia2.snapshots
         -DpomFile=gms-client/gms-client/pom.xml
         -Durl=${IA2_MVN_REPO_SNAPSHOTS}
-  only:
-    - master
+
+dockerize_db:
+  stage: deploy
+  tags:
+    - shell
+  script:
+    - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
+    - docker build -t "${CI_REGISTRY_IMAGE}/database" -f database/Dockerfile .
+    - docker push "${CI_REGISTRY_IMAGE}/database"
+  rules:
+    - if: '$CI_COMMIT_BRANCH != "master"'
+      when: never
+    - changes:
+        - database/*
+        - gms/src/main/resources/sql/*
+
+dockerize_gms:
+  stage: deploy
+  tags:
+    - shell
+  script:
+    - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
+    - docker build -t "${CI_REGISTRY_IMAGE}" -f gms/Dockerfile .
+    - docker push "${CI_REGISTRY_IMAGE}"
+  rules:
+    - if: '$CI_COMMIT_BRANCH != "master"'
+      when: never
+    - changes:
+        - gms/*
+        - gms-ui/*