From 9bde6ea8f3f95b7fa11685e86d82b8c25f1ee3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Cotineau?= Date: Fri, 12 Apr 2024 10:08:10 +0200 Subject: [PATCH] SONAR-19108 fix docker compose example app replica issue * SONAR-19108 fix docker compose example app replica issue * Suggestions for limits and postgres image version --------- Co-authored-by: Carmine Vassallo --- .../sq-dce-postgres/docker-compose.yml | 41 ++++++++++++++----- .../sq-with-postgres/docker-compose.yml | 10 ++++- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/example-compose-files/sq-dce-postgres/docker-compose.yml b/example-compose-files/sq-dce-postgres/docker-compose.yml index ad2371e40..21a14c772 100644 --- a/example-compose-files/sq-dce-postgres/docker-compose.yml +++ b/example-compose-files/sq-dce-postgres/docker-compose.yml @@ -2,6 +2,14 @@ version: "3" services: sonarqube: + deploy: + replicas: 3 + healthcheck: + test: wget --no-proxy -qO- http://localhost:9000/api/system/status | grep -q -e '"status":"UP"' -e '"status":"DB_MIGRATION_NEEDED"' -e '"status":"DB_MIGRATION_RUNNING"' + interval: 25s + timeout: 1s + retries: 3 + start_period: 55s image: sonarqube:datacenter-app depends_on: search-1: @@ -10,11 +18,13 @@ services: condition: service_healthy search-3: condition: service_healthy + db: + condition: service_healthy networks: - sonar-network cpus: 0.5 mem_limit: 4096M - mem_reservation: 1024M + mem_reservation: 4096M environment: SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar SONAR_JDBC_USERNAME: sonar @@ -22,6 +32,7 @@ services: SONAR_WEB_PORT: 9000 SONAR_CLUSTER_SEARCH_HOSTS: "search-1,search-2,search-3" SONAR_CLUSTER_HOSTS: "sonarqube" + SONAR_CLUSTER_KUBERNETES: true SONAR_AUTH_JWTBASE64HS256SECRET: "dZ0EB0KxnF++nr5+4vfTCaun/eWbv6gOoXodiAMqcFo=" VIRTUAL_HOST: sonarqube.dev.local VIRTUAL_PORT: 9000 @@ -32,10 +43,11 @@ services: image: sonarqube:datacenter-search hostname: "search-1" cpus: 0.5 - mem_limit: 4096M - mem_reservation: 1024M + mem_limit: 3072M + mem_reservation: 3072M depends_on: - - db + db: + condition: service_healthy networks: - sonar-network environment: @@ -56,10 +68,11 @@ services: image: sonarqube:datacenter-search hostname: "search-2" cpus: 0.5 - mem_limit: 4096M - mem_reservation: 1024M + mem_limit: 3072M + mem_reservation: 3072M depends_on: - - db + db: + condition: service_healthy networks: - sonar-network environment: @@ -80,10 +93,11 @@ services: image: sonarqube:datacenter-search hostname: "search-3" cpus: 0.5 - mem_limit: 4096M - mem_reservation: 1024M + mem_limit: 3072M + mem_reservation: 3072M depends_on: - - db + db: + condition: service_healthy networks: - sonar-network environment: @@ -101,7 +115,12 @@ services: retries: 3 start_period: 55s db: - image: postgres:13 + image: postgres:15 + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 networks: - sonar-network environment: diff --git a/example-compose-files/sq-with-postgres/docker-compose.yml b/example-compose-files/sq-with-postgres/docker-compose.yml index cfcdcd972..33c5ec3f6 100644 --- a/example-compose-files/sq-with-postgres/docker-compose.yml +++ b/example-compose-files/sq-with-postgres/docker-compose.yml @@ -5,7 +5,8 @@ services: hostname: sonarqube container_name: sonarqube depends_on: - - db + db: + condition: service_healthy environment: SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar SONAR_JDBC_USERNAME: sonar @@ -17,7 +18,12 @@ services: ports: - "9000:9000" db: - image: postgres:13 + image: postgres:15 + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 hostname: postgresql container_name: postgresql environment: