安装docker-compose
安装docker
创建容器运行的特有网络
创建挂载目录
version: "3"
services:
sonar-postgres:
image: postgres:14.4
networks:
- gitlab
container_name: pgsql
volumes:
- "/data/pgsql/data:/var/lib/postgresql/data"
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar@123
- TZ=Asia/Shanghai
sonarqube:
image: sonarqube:8.9-community
container_name: sonar
networks:
- gitlab
environment:
- TZ=Asia/Shanghai
- SONARQUBE_JDBC_USERNAME=sonar
- SONARQUBE_JDBC_PASSWORD=sonar@123
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-postgres:5432/sonar
volumes:
- "/data/sonar/data:/opt/sonarqube/data"
- "/data/sonar/logs:/opt/sonarqube/logs"
- "/data/sonar/extensions:/opt/sonarqube/extensions"
ports:
- "9000:9000"
depends_on:
- sonar-postgres
networks:
gitlab:
driver: bridge
docker-compose -f docker-compose-sonar.yml up -d
Administration -> Configuration -> ALM integrations -> GitLab -> **Create configuration
参考: https://docs.sonarqube.org/9.7/instance-administration/authentication/gitlab/