Skip to content

Instantly share code, notes, and snippets.

@Warchant
Last active May 28, 2024 20:24
Show Gist options
  • Save Warchant/0d0f0104fe7adf3b310937d2db67b512 to your computer and use it in GitHub Desktop.
Save Warchant/0d0f0104fe7adf3b310937d2db67b512 to your computer and use it in GitHub Desktop.
docker-compose file to setup production-ready sonarqube
version: "3"
services:
sonarqube:
image: sonarqube
expose:
- 9000
ports:
- "127.0.0.1:9000:9000"
networks:
- sonarnet
environment:
- sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
- sonar.jdbc.username=sonar
- sonar.jdbc.password=sonar
volumes:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
db:
image: postgres
networks:
- sonarnet
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
networks:
sonarnet:
volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data:
@kozla13
Copy link

kozla13 commented May 5, 2023

how to set the init admin username and password ?

@aawoyemi142
Copy link

aawoyemi142 commented May 5, 2023 via email

@kozla13
Copy link

kozla13 commented May 5, 2023

i want just to automate some stuff for local development

@Warchant
Copy link
Author

Warchant commented May 9, 2023 via email

@itsecforu
Copy link

itsecforu commented May 11, 2023

$ docker ps -q | xargs  docker stats --no-stream
$ k8s_database_harbor-harbor-database-0_harbor_62dc87ee-0df7-4359-9425-bf135bcc79a3_0  
                    910.31%  ```

@FlorianWolters
Copy link

FlorianWolters commented Jun 20, 2023

Just my 2 cents:

  1. The "official" docker-compose.yml usage example for Sonarqube with PostgreSQL can be found here.

  2. I was able to start SonarQube v10 + PostgreSQL v15.3 on a Windows 11 machine with the following docker-compose.yml file.

  3. Edit: The alternative for SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true seems to be the following:

    1. Create (or edit) the file %USERPROFILE%\.wslconfig.

    2. Add the following:

      [wsl2]
      kernelCommandLine="sysctl.vm.max_map_count=262144"
      

docker-compose.yml:

version: "3"

services:
  sonarqube:
    image: sonarqube:10.0.0-community
    hostname: sonarqube
    container_name: local-sonarqube
    depends_on:
      - db
    environment:
      - SONAR_JDBC_URL=jdbc:postgresql://db:5432/sonar
      - SONAR_JDBC_USERNAME=sonar
      - SONAR_JDBC_PASSWORD=sonar
      # The following (commented out) setting is a workaround for the following error:
      #
      #     max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
      #
      # It is better to add the following to the file `%USERPROFILE%\.wslconfig` on Windows instead:
      #
      #     [wsl2]
      #     kernelCommandLine="sysctl.vm.max_map_count=262144"
      #- SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
    ports:
      - "9000:9000"
  db:
    image: postgres:15.3
    hostname: postgres
    container_name: local-postgres-for-sonarqube
    environment:
      - POSTGRES_USER=sonar
      - POSTGRES_PASSWORD=sonar
      - POSTGRES_DB=sonar
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data

volumes:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_logs:
  postgresql:
  postgresql_data:

@fabi6ferreira
Copy link

Thank you @Warchant . It works for me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment