docker compose 部署sonar

通过docker-compose来部署sonar

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
version: '3'
services:
  postgres:
    image: postgres:latest
    container_name: postgres
    restart: always
    privileged: true
    networks:
      - sonar
    volumes:
      - /data/sonar/postgres/postgresql:/var/lib/postgresql
      - /data/sonar/postgres/data:/var/lib/postgresql/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: sonar 
      POSTGRES_PASSWORD: sonar 
      POSTGRES_DB: sonar 
      TZ: Asia/Shanghai 

  sonar:
    image: sonarqube:8.9.10-community
    container_name: sonar
    restart: always
    privileged: true
    networks:
      - sonar
    volumes:
      - /data/sonar/sonarqube/logs:/opt/sonarqube/logs
      - /data/sonar/sonarqube/conf:/opt/sonarqube/conf
      - /data/sonar/sonarqube/data:/opt/sonarqube/data
      - /data/sonar/sonarqube/extensions:/opt/sonarqube/extensions
    ports:
      - "9090:9000"
    links:
      - "postgres:postgres"  
    environment:
      ALLOW_EMPTY_PASSWORD: "yes"
      SONARQUBE_JDBC_USERNAME: sonar
      SONARQUBE_JDBC_PASSWORD: sonar
      SONARQUBE_JDBC_URL: "jdbc:postgresql://postgres:5432/sonar" 

networks:
  sonar:
    driver: bridge

创建的命令

1
2
3
4
5
6
7
mkdir -p /data/sonar/postgres/postgresql
mkdir -p /data/sonar/postgres/data

mkdir -p /data/sonar/sonarqube
chmod 777 -R /data/sonar/sonarqube
echo "vm.max_map_count=262144" > /etc/sysctl.conf
sysctl -p

第一次登录用户名和密码都是admin、admin,登录成功后需要修改密码

接下来离线安装中文报

1
2
3
cd sonarqube/extensions/downloads/

wget https://github.com/xuhuisheng/sonar-l10n-zh/releases/download/sonar-l10n-zh-plugin-1.24/sonar-l10n-zh-plugin-1.24.jar

接下来重启服务即可 接下来手动新建项目进行sonar scan

1
2
3
4
5

mvn sonar:sonar \
  -Dsonar.projectKey=dash \
  -Dsonar.host.url=http://10.7.20.32229:9090 \
  -Dsonar.login=83e7a37abef1c0b12b4f9a5dbe02e96afc5d9f9d
Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up