Skip to content

Instantly share code, notes, and snippets.

@peavers
Created April 17, 2021 07:10
Show Gist options
  • Save peavers/e19fca3efcbc5be975f11624d62354e7 to your computer and use it in GitHub Desktop.
Save peavers/e19fca3efcbc5be975f11624d62354e7 to your computer and use it in GitHub Desktop.
Complete SonarQube with reverse proxy
# SSL Certificates
DOMAIN=example.copm # Set this to the domain you want a certificate for, sonar will be available at it on /sonar
EMAIL=[email protected] # Need a valid email for the certificate generation
# Directories
USERDIR=/${HOME}/docker # Change this to where you'd like to store SonarQube configuration on your host machine
# Sonar
SONAR_DATABASE_USER=sonar # Make sure to change this
SONAR_DATABASE_PASSWORD=sonar # Make sure to change this
version: "3"
services:
traefik:
container_name: traefik
image: traefik:v2.2
restart: unless-stopped
command:
- --api
- --providers.docker
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true
- --entrypoints.websecure.address=:443
- --certificatesresolvers.leresolver.acme.caserver=https://acme-v02.api.letsencrypt.org/directory
- --certificatesresolvers.leresolver.acme.email=${EMAIL}
- --certificatesresolvers.leresolver.acme.storage=/app/acme.json
- --certificatesresolvers.leresolver.acme.tlschallenge=true
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${USERDIR}/traefik:/app
logging:
options:
max-size: "2m"
max-file: "5"
sonarqube:
container_name: sonarqube
image: sonarqube:latest
restart: unless-stopped
cpus: 0.5
mem_limit: 4096M
mem_reservation: 1024M
environment:
- SONAR_JDBC_URL=jdbc:postgresql://sonarqube-postgres:5432/sonar
- SONAR_JDBC_USERNAME=${SONAR_DATABASE_USER}
- SONAR_JDBC_PASSWORD=${SONAR_DATABASE_PASSWORD}
- SONAR_WEB_CONTEXT=/sonar
volumes:
- ${USERDIR}/sonarqube/conf:/opt/sonarqube/conf
- ${USERDIR}/sonarqube/data:/opt/sonarqube/data
- ${USERDIR}/sonarqube/extensions:/opt/sonarqube/extensions
- ${USERDIR}/sonarqube/bundled-plugins:/opt/sonarqube/lib/bundled-plugins
depends_on:
- traefik
- sonarqube-postgres
logging:
options:
max-size: "2m"
max-file: "5"
labels:
- "traefik.http.routers.sonarqube.rule=Host(`${DOMAIN}`) && PathPrefix(`/sonar`)"
- "traefik.http.routers.sonarqube.tls=true"
sonarqube-postgres:
container_name: sonarqube-postgres
image: postgres
restart: unless-stopped
environment:
- POSTGRES_USER=${SONAR_DATABASE_USER}
- POSTGRES_PASSWORD=${SONAR_DATABASE_PASSWORD}
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
labels:
- traefik.enable=false
ulimits:
nofile:
soft: 65536
hard: 65536
volumes:
postgresql:
postgresql_data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment