version: '3.9'

services:
  app:
    image: git.lehmannhaus.de/tobiaslehmann/sonarqube.with.sso:latest
    depends_on:
      - db
    environment:
      - USER_UID={{ service_user_id }}
      - USER_GID={{ service_group_id }}
      - SONAR_JDBC_URL=${DB_URL}
      - SONAR_JDBC_USERNAME=${DB_USER}
      - SONAR_JDBC_PASSWORD=${DB_PASSWORD}
    restart: always
    volumes:
      - {{ service_directory }}/data/appdata/data:/opt/sonarqube/data
      - {{ service_directory }}/data/appdata/logs:/opt/sonarqube/logs
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - '9000:9000'
    networks:
      - default

  db:
    image: postgres:14    
    restart: always
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    networks:
      - default 
    volumes:
      - {{ service_directory }}/data/db:/var/lib/postgresql/data

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.3.0.0/16
          gateway: 172.3.0.1