diff --git a/sonarqube/Dockerfile b/sonarqube/Dockerfile new file mode 100644 index 0000000..451bbcb --- /dev/null +++ b/sonarqube/Dockerfile @@ -0,0 +1,5 @@ +FROM sonarqube + +COPY --chown=sonarqube:sonarqube docker-healthcheck /usr/local/bin/ + +HEALTHCHECK CMD ["docker-healthcheck"] diff --git a/sonarqube/docker-healthcheck b/sonarqube/docker-healthcheck new file mode 100755 index 0000000..76f5c5a --- /dev/null +++ b/sonarqube/docker-healthcheck @@ -0,0 +1,10 @@ +#!/bin/bash + +# A Sonarqube container is considered healthy if the status is UP, DB_MIGRATION_NEEDED or DB_MIGRATION_RUNNING +# status about migration are added to prevent the node to be kill while sonarqube is updating himself. + +if curl -Ss http://localhost:9000/api/system/status | grep -q -e '"status":"UP"' -e '"status":"DB_MIGRATION_NEEDED"' -e '"status":"DB_MIGRATION_RUNNING"'; then + exit 0 +fi + +exit 1