Last active
September 10, 2020 17:49
-
-
Save benwarfield-usds/76890bda27d2588f8090cc0ce8eb7cad to your computer and use it in GitHub Desktop.
A docker-compose configuration for running Sonarqube locally
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
version: "3.2" | |
services: | |
sonar-db: | |
image: "postgres" | |
volumes: | |
# Create/use a named volume so that the database is not wiped if we recreate the container | |
- type: volume | |
source: sonarqube-db-data | |
target: /var/lib/postgresql/data | |
# This only works on MacOS Docker, but I can live with that for now | |
- type: bind | |
source: ./sonar-db-setup.sh | |
target: /docker-entrypoint-initdb.d/01-user-schema-creation.sh | |
sonar: | |
image: sonarqube:8-community | |
environment: | |
SONAR_JDBC_USERNAME: sonarqube | |
SONAR_JDBC_URL: jdbc:postgresql://sonar-db/sonardb?currentSchema=sonar | |
# SONAR_WEB_PORT is 9000 by default and we don't need to change it internally | |
ports: | |
- "${SONAR_PORT:-9000}:9000" | |
volumes: | |
sonarqube-db-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
createuser -U "$POSTGRES_USER" -w sonarqube | |
createdb -U "$POSTGRES_USER" -w sonardb --maintenance-db="$POSTGRES_DB" | |
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" sonardb <<-SQL | |
CREATE SCHEMA IF NOT EXISTS sonar; | |
GRANT ALL PRIVILEGES ON SCHEMA sonar TO sonarqube; | |
SQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment