文章目录
-
- [1. 前置条件](#1. 前置条件)
- [2. 编写docker-compose-sonar.yml文件](#2. 编写docker-compose-sonar.yml文件)
- [3. 集成 gitlab](#3. 集成 gitlab)
- [4. Sonar Login with GitLab](#4. Sonar Login with GitLab)
1. 前置条件
安装docker-compose
安装docker
创建容器运行的特有网络
创建挂载目录
2. 编写docker-compose-sonar.yml文件
bash
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
bash
docker-compose -f docker-compose-sonar.yml up -d
3. 集成 gitlab
Administration -> Configuration -> ALM integrations -> GitLab -> **Create configuration
4. Sonar Login with GitLab
参考: https://docs.sonarqube.org/9.7/instance-administration/authentication/gitlab/