Skip to content

SonarQube and CABL in Docker containers

Gilles QUERRET edited this page May 6, 2021 · 4 revisions

SonarQube is available on Docker Hub, making it easy to test CABL in this environment. Here are two Docker Compose files that we use internally. The first one is using a remote database (with Amazon RDP to be precise), while the second one is using a local Postgres instance also started as a Docker container.

Example 1

version: '3'
volumes:
  sonarqube-data:
  sonarqube-logs:
  sonarqube-extensions:

services:
  sonarqube:
    image: sonarqube:8.9-developer # use 8.9-community if you don't have a license for SonarQube developer edition
    restart: always
    volumes:
    - sonarqube-data:/opt/sonarqube/data
    - sonarqube-extensions:/opt/sonarqube/extensions
    - sonarqube-logs:/opt/sonarqube/logs
    environment:
    - SONAR_JDBC_USERNAME=pgadmin
    - SONAR_JDBC_PASSWORD=your_password_here
    - SONAR_JDBC_URL=jdbc:postgresql://sonar.xxxxx.eu-west-1.rds.amazonaws.com/sonar
    - SONAR_AUTH_JWTBASE64HS256SECRET=xxxxx # Use echo -n "type_what_you_want" | openssl dgst -sha256 -hmac "key" -binary | base64
    ports:
    - xxxx:9000 # Expose port
    ulimits:
      nofile:
        soft: 65536
        hard: 65536

Example 2

version: '3'
volumes:
  postgres-db:
  sonarqube-data:
  sonarqube-logs:
  sonarqube-extensions:

services:
  postgres:
    image: postgres:12.1-alpine
    restart: always
    volumes:
    - postgres-db:/var/lib/postgresql/data
    environment:
    - POSTGRES_PASSWORD=sonarqube
  sonarqube:
    image: sonarqube:8.9-community
    restart: always
    volumes:
    - sonarqube-data:/opt/sonarqube/data
    - sonarqube-extensions:/opt/sonarqube/extensions
    - sonarqube-logs:/opt/sonarqube/logs
    environment:
    - SONAR_JDBC_USERNAME=sonar
    - SONAR_JDBC_PASSWORD=sonarqube
    - SONAR_JDBC_URL=jdbc:postgresql://postgres/sonar
    - SONAR_AUTH_JWTBASE64HS256SECRET=xxxxx # Use echo -n "type_what_you_want" | openssl dgst -sha256 -hmac "key" -binary | base64
    links:
    - postgres
    ports:
    - xxxx:9000 # Expose port
    ulimits:
      nofile:
        soft: 65536
        hard: 65536

Install CABL

Once SonarQube is up and running, copy the JAR files from the latest release to the downloads directory of your sonarqube-extensions Docker volume, and restart the instance. You'll then be able to install your license using the standard process