From 990c7ac93a55d020f6dbb52244b60484a075f3f4 Mon Sep 17 00:00:00 2001 From: Janos Gyerik Date: Thu, 22 Nov 2018 17:04:08 +0100 Subject: [PATCH 1/2] SonarQube 7.4 and 6.7.6 and cleaner better docs --- sonarqube/content.md | 87 ++++++++++++++++++++++++++++++------------- sonarqube/get-help.md | 1 + 2 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 sonarqube/get-help.md diff --git a/sonarqube/content.md b/sonarqube/content.md index f6d0fde44..a346be2d6 100644 --- a/sonarqube/content.md +++ b/sonarqube/content.md @@ -1,50 +1,87 @@ # What is SonarQube? -SonarQube is an open source platform for continuous inspection of code quality. - -> [wikipedia.org/wiki/SonarQube](http://en.wikipedia.org/wiki/SonarQube) +[SonarQube](https://www.sonarqube.org/) is an open source product for continuous inspection of code quality. %%LOGO%% # How to use this image +This Docker image contains the Community Edition of SonarQube. + +The image is based on `openjdk:8`. We don't provide a build based on `openjdk:8-alpine`, because it seems [broken in Linux](https://github.com/docker-library/openjdk/issues/250). + ## Run SonarQube The server is started this way: -```console -$ docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 %%IMAGE%% -``` + docker run -d --name sonarqube -p 9000:9000 %%IMAGE%% -By default you can login as `admin` with password `admin`, see [authentication](https://docs.sonarqube.org/display/SONAR/Authentication). +By default you can login as `admin` with password `admin`, see [authentication documentation](https://docs.sonarqube.org/latest/instance-administration/security/). -To analyse a project: +To analyze a Maven project: -```console -$ On Linux: -mvn sonar:sonar + # On Linux: + mvn sonar:sonar + + # With boot2docker: + mvn sonar:sonar -Dsonar.host.url=http://$(boot2docker ip):9000 -$ With boot2docker: -mvn sonar:sonar -Dsonar.host.url=http://$(boot2docker ip):9000 -Dsonar.jdbc.url="jdbc:h2:tcp://$(boot2docker ip)/sonar" -``` +To analyze other kinds of projects and for more details see [Analyzing Source Code documentation](https://redirect.sonarsource.com/doc/analyzing-source-code.html). -## Database configuration +## Advanced configuration + +### Option 1: Database configuration By default, the image will use an embedded H2 database that is not suited for production. -The production database is configured with these variables: `SONARQUBE_JDBC_USERNAME`, `SONARQUBE_JDBC_PASSWORD` and `SONARQUBE_JDBC_URL`. +The production database is configured with the following SonarQube properties used as environment variables: `sonar.jdbc.username`, `sonar.jdbc.password` and `sonar.jdbc.url`. -```console -$ docker run -d --name sonarqube \ - -p 9000:9000 -p 9092:9092 \ - -e SONARQUBE_JDBC_USERNAME=sonar \ - -e SONARQUBE_JDBC_PASSWORD=sonar \ - -e SONARQUBE_JDBC_URL=jdbc:postgresql://localhost/sonar \ - sonarqube -``` + docker run -d --name sonarqube \ + -p 9000:9000 \ + -e sonar.jdbc.username=sonar \ + -e sonar.jdbc.password=sonar \ + -e sonar.jdbc.url=jdbc:postgresql://localhost/sonar \ + sonarqube + +Use of the environment variables `SONARQUBE_JDBC_USERNAME`, `SONARQUBE_JDBC_PASSWORD` and `SONARQUBE_JDBC_URL` is deprecated, and will stop working in future releases. More recipes can be found [here](https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md). +### Option 2: Use parameters via Docker environment variables + +You can pass `sonar.` configuration properties as Docker environment variables, as demonstrated in the example above for database configuration. + +### Option 3: Use bind-mounted persistent volumes + +The images contain the SonarQube installation at `/opt/sonarqube`. You can use bind-mounted persistent volumes to override selected files or directories, for example: + +- `sonarqube_conf:/opt/sonarqube/conf`: configuration files, such as `sonar.properties` +- `sonarqube_data:/opt/sonarqube/data`: data files, such as the embedded H2 database and Elasticsearch indexes +- `sonarqube_logs:/opt/sonarqube/logs` +- `sonarqube_extensions:/opt/sonarqube/extensions`: plugins, such as language analyzers + +You could also use bind-mounted configurations specified on the command line, for example: + + docker run -d --name sonarqube \ + -p 9000:9000 \ + -v /path/to/conf:/opt/sonarqube/conf \ + -v /path/to/data:/opt/sonarqube/data \ + -v /path/to/logs:/opt/sonarqube/logs \ + -v /path/to/extensions:/opt/sonarqube/extensions \ + sonarqube + +### Option 4: Customized image + +In some environments, it may make more sense to prepare a custom image containing your configuration. A `Dockerfile` to achieve this may be as simple as: + + FROM sonarqube:7.4-community + COPY sonar.properties /opt/sonarqube/conf/ + +You could then build and try the image with something like: + + docker build --tag=sonarqube-custom . + docker run -ti sonarqube-custom + ## Administration -The administration guide can be found [here](http://docs.sonarqube.org/display/SONAR/Administration+Guide). +The administration guide can be found [here](https://redirect.sonarsource.com/doc/administration-guide.html). diff --git a/sonarqube/get-help.md b/sonarqube/get-help.md new file mode 100644 index 000000000..271e6eddf --- /dev/null +++ b/sonarqube/get-help.md @@ -0,0 +1 @@ +[the SonarSource Community forum](https://community.sonarsource.com/tags/c/help/sq/docker), [the Docker Community Forums](https://forums.docker.com/), [the Docker Community Slack](https://blog.docker.com/2016/11/introducing-docker-community-directory-docker-community-slack/), or [Stack Overflow](https://stackoverflow.com/search?tab=newest&q=docker) From e9810972d497946919d9366b8cfe30b1f41507a1 Mon Sep 17 00:00:00 2001 From: Janos Gyerik Date: Tue, 27 Nov 2018 17:24:39 +0100 Subject: [PATCH 2/2] Drop the note about the base (the default is now alpine) --- sonarqube/content.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/sonarqube/content.md b/sonarqube/content.md index a346be2d6..61c7c5583 100644 --- a/sonarqube/content.md +++ b/sonarqube/content.md @@ -8,8 +8,6 @@ This Docker image contains the Community Edition of SonarQube. -The image is based on `openjdk:8`. We don't provide a build based on `openjdk:8-alpine`, because it seems [broken in Linux](https://github.com/docker-library/openjdk/issues/250). - ## Run SonarQube The server is started this way: