# https://juejin.cn/post/7027362354547392526
version: '3'
services:
  # postgres:
  #   image: postgres:12
  #   restart: always
  #   container_name: postgres
  #   ports:
  #     - 5432:5432
  #   volumes:
  #     - /opt/postgres/postgresql/:/var/lib/postgresql
  #     - /opt/postgres/data/:/var/lib/postgresql/data
  #   environment:
  #     TZ: Asia/Shanghai
  #     POSTGRES_USER: sonar
  #     POSTGRES_PASSWORD: sonar123
  #     POSTGRES_DB: sonar
  #   networks:
  #     - sonar-network
  sonar:
    image: sonarqube:9.8-community
    restart: always
    container_name: sonar
    # depends_on:
    #   - postgres
    volumes:
      - ./extensions:/opt/sonarqube/extensions
      - ./logs:/opt/sonarqube/logs
      - ./data:/opt/sonarqube/data
      - ./conf:/opt/sonarqube/conf
    ports:
      - 9000:9000
    environment:
      SONARQUBE_JDBC_USERNAME: postgres
      SONARQUBE_JDBC_PASSWORD: root
      SONARQUBE_JDBC_URL: jdbc:postgresql://192.168.31.249:5432/postgres
    networks:
      - sonar-network
networks:
  sonar-network:
    driver: bridge