# ignore: true
# documentation: https://hub.docker.com/_/sonarqube/
# slogan: SonarQube is a self-managed, automatic code review tool that systematically helps you deliver Clean Code
# tags: sonarqube, code-review, clean-code, quality, code-quality, code-analysis, code-smells, code-coverage, code-security

services:
  sonarqube:
    image: sonarqube:community
    environment:
      - SERVICE_FQDN_SONARQUBE_9000
      - SONAR_JDBC_URL=jdbc:postgresql://postgresql:5432/${POSTGRES_DB:-sonar}
      - SONAR_JDBC_USERNAME=$SERVICE_USER_POSTGRES
      - SONAR_JDBC_PASSWORD=$SERVICE_PASSWORD_POSTGRES
    volumes:
      - sonarqube-data:/opt/sonarqube
      - sonarqube-conf:/opt/sonarqube/conf
      - sonarqube-extensions:/opt/sonarqube/extensions
      - sonarqube-logs:/opt/sonarqube/logs
      - sonarqube-bundled-plugins:/opt/sonarqube/lib/bundled-plugins
    depends_on:
      postgresql:
        condition: service_healthy
  postgresql:
    image: postgres:16-alpine
    volumes:
      - postgresql-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=$SERVICE_USER_POSTGRES
      - POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES
      - POSTGRES_DB=${POSTGRES_DB:-sonar}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 5s
      timeout: 20s
      retries: 10

