4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker環境でSonarQubeを構築する

Last updated at Posted at 2016-08-22

概要

静的コード解析ツールであるSonarQubeをDockerを使って構築してみました。

手順

MySQL設定&起動

MySQL用のデータボリュームコンテナを作成。

$ docker run -d \
-v /usr/local/data/mysql-sonarqube:/var/lib/mysql \
--name busybox-sonarqube \
busybox true

MySQL用の設定ファイルを作成。

/usr/local/data/mysql-sonarqube-conf/custom.cnf
[mysqld]
character-set-server=utf8

[client]
default-character-set=utf8

MySQL起動。

$ docker run -d \
--name mysql-sonarqube \
--volumes-from busybox-sonarqube \
-v /usr/local/data/mysql-sonarqube-conf:/etc/mysql/conf.d \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=XXX \
mysql

MySQLのコンテナに入ってSonarQube用のDBを作成。

CREATE DATABASE sonar CHARACTER SET utf8;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

SonarQube起動

$ docker run -d \
--name sonarqube \
--link mysql-sonarqube:mysql \
-p 9000:9000 \
-p 9092:9092 \
-e SONARQUBE_JDBC_USERNAME=sonar \
-e SONARQUBE_JDBC_PASSWORD=sonar \
-e "SONARQUBE_JDBC_URL=jdbc:mysql://mysql:3306/sonar?useUnicode=true&characterEncoding=utf8" \
sonarqube

ブラウザから確認

「http://[サーバのアドレス]:9000/」にアクセスしてSonarQubeのDashboardが表示されたら成功です。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?