docker run --rm --network host \
-e SONAR_HOST_URL="http://localhost:9000" \
-e SONAR_LOGIN="admin" \
-e SONAR_PASSWORD="{{PASSWORD}}" \
-e SONAR_PROJECT_KEY="{{PROJECT_KEY}}" \
-v $PWD:/usr/src \
-v $PWD/dockers/sonar/sonar-project.properties:/opt/sonar-scanner/conf/sonar-scanner.properties \
sonarsource/sonar-scanner-cli -Dsonar.projectKey="rendevor-1"
Created
July 19, 2024 14:49
-
-
Save GuilhermeCunha/ed5a55b9e730cb2a984ed2ef40a1e9a7 to your computer and use it in GitHub Desktop.
How to setup dockerqube with docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SONAR_USERNAME=admin | |
SONAR_WEB_PASSWORD= | |
SONAR_PASSWORD= | |
SONAR_PROJECTKEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Based on https://hub.docker.com/_/sonarqube | |
# | |
version: '3.7' | |
services: | |
sonarqube: | |
image: sonarqube:lts-community | |
ports: | |
- '9000:9000' | |
env_file: | |
- .env | |
healthcheck: | |
test: | |
[ | |
'CMD-SHELL', | |
'if wget -qO- 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;', | |
] | |
interval: 5s | |
timeout: 60s | |
retries: 10 | |
environment: | |
- SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonar | |
- SONAR_WEB_SYSTEMPASSCODE=${SONAR_PASSWORD} | |
- SONAR_JDBC_USERNAME=${SONAR_USERNAME} | |
- SONAR_JDBC_PASSWORD=${SONAR_PASSWORD} | |
# See more in https://docs.sonarsource.com/sonarqube/9.9/setup-and-upgrade/configure-and-operate-a-server/environment-variables/ | |
networks: | |
- sonarnet | |
volumes: | |
- sonarqube_conf:/opt/sonarqube/conf | |
- sonarqube_data:/opt/sonarqube/data | |
- sonarqube_logs:/opt/sonarqube/logs | |
- sonarqube_extensions:/opt/sonarqube/extensions | |
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins | |
db: | |
container_name: sonardb | |
image: postgres | |
env_file: | |
- .env | |
networks: | |
- sonarnet | |
environment: | |
- POSTGRES_USER=${SONAR_USERNAME} | |
- POSTGRES_PASSWORD=${SONAR_PASSWORD} | |
volumes: | |
- postgresql:/var/lib/postgresql | |
- postgresql_data:/var/lib/postgresql/data | |
networks: | |
sonarnet: | |
volumes: | |
sonarqube_conf: | |
sonarqube_data: | |
sonarqube_logs: | |
sonarqube_extensions: | |
sonarqube_bundled-plugins: | |
postgresql: | |
postgresql_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# must be unique in a given SonarQube instance | |
sonar.projectKey={{PROJECT_KEY}} | |
# --- optional properties --- | |
# defaults to project key | |
#sonar.projectName=My project | |
# defaults to 'not provided' | |
#sonar.projectVersion=1.0 | |
# Path is relative to the sonar-project.properties file. Defaults to . | |
sonar.sources=. | |
# Encoding of the source code. Default is default system encoding | |
sonar.sourceEncoding=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# per https://hub.docker.com/_/sonarqube | |
# to be executed before launching the app | |
sysctl -w vm.max_map_count=262144 | |
sysctl -w fs.file-max=65536 | |
ulimit -n 65536 | |
ulimit -u 4096 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment