Docker sonar本地搭建

栏目: 数据库 · 发布时间: 7年前

内容简介:查看所有用户创建数据库创建角色

1、数据库操作:

进去数据库复制代码
psql -U postgres  -h 127.0.0.1 
复制代码

查看所有用户

postgres=# \du复制代码

创建数据库

CREATE DATABASE sonar复制代码

创建角色

CREATE  ROLE sonar
ALTER ROLE sonar WITH LOGIN;复制代码

2、 Docker 构建sonar镜像(SONARQUBE_JDBC_URL:更改成自己的数据库地址,案例ip为:192.168.0.25)

镜像构建

docker run -d --name sonarqube \
    -p 8888:9000 -p 9092:9092 \
    -e SONARQUBE_JDBC_USERNAME=sonar \
    -e SONARQUBE_JDBC_PASSWORD=sonar \
    -e SONARQUBE_JDBC_URL=jdbc:postgresql://192.168.0.25/postgres \
    -d  sonarqube复制代码

登录:

http://192.168.0.25:8888/about复制代码

默认账号密码为:

admin,admin复制代码

插件安装:(Chinese Pack 插件安装和CheckStyle 插件安装)

点击 配置 -> 系统 -> 更新中心 -> Available -> Search,输入 CheckStyle,在搜素结果中找到 对应 插件点击 Install,等待下载完成后,按照页面提示点击 Restart 自动重启服务即可完成安装。

Docker sonar本地搭建

3上传项目到sonar

maven配置:

<settings> <pluginGroups>
        <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
    </pluginGroups>  <profiles> <profile> <id>sonar</id>  <activation>  <activeByDefault>true</activeByDefault>
            </activation> <properties>  <!-- 配置 Sonar Host地址,默认:http://localhost:9000 -->
                <sonar.host.url>            http://myserver:9000
                </sonar.host.url> </properties>  </profile>  </profiles> </settings>

复制代码

项目配置:

如果我们想指定使用某个版本的 sonar-maven-plugin 插件,比如 3.3.0.603 版本,可以有两种方式:

一、修改 pom.xml 文件

<build>
  <plugins>
    <plugin>
      <groupId>org.sonarsource.scanner.maven</groupId>
      <artifactId>sonar-maven-plugin</artifactId>
      <version>3.3.0.603</version>
    </plugin>
  </plugins>
</build> 

复制代码

二、使用 mvn 命令指定

mvn clean install -DskipTests=true  org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar复制代码

4、上传项目到镜像仓库:

进去配置文件: /etc/docker/daemon.json

{
  "registry-mirrors": ["https://3itj1ym2.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.199.201"],#这里修改你对应的仓库地址,即harbor地址
  "hosts": [
    "tcp://0.0.0.0:2375",
    "unix:///var/run/docker.sock"
  ]
}复制代码

进去配置文件:/lib/systemd/system/docker.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd#去掉后面的东西
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always复制代码

重启

sudo chmod -R 777 /var/run/docker.sock
sudo systemctl daemon-reload
sudo systemctl start docker
sudo systemctl enable docker复制代码

登录:docker login 192.168.0.7(写入账户密码)

执行:(这里需要配置 dockerfile-maven-plugi插件

mvn clean deploy -U -DskipTests=true -P yiye_two_test   复制代码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Coming of Age in Second Life

Coming of Age in Second Life

Tom Boellstorff / Princeton University Press / 2008-04-21 / USD 29.95

The gap between the virtual and the physical, and its effect on the ideas of personhood and relationships, is the most interesting aspect of Boellstorff's analysis... Boellstorff's portrayal of a virt......一起来看看 《Coming of Age in Second Life》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试