Merge pull request #20 from pierre-guillot-sonarsource/feature/MMF-1777/add_healthcheck

Add sonarqube healthcheck example
This commit is contained in:
Tianon Gravi 2019-07-25 15:44:54 -07:00 committed by GitHub
commit eb12c27210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

5
sonarqube/Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM sonarqube
COPY docker-healthcheck /usr/local/bin/
HEALTHCHECK CMD ["docker-healthcheck"]

11
sonarqube/docker-healthcheck Executable file
View File

@ -0,0 +1,11 @@
#!/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.
host="$(hostname --ip-address || echo '127.0.0.1')"
if curl -Ss http://${host}: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