Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually installing SonarQube plugins on Docker image

I want to create my custom SonarQube docker image, with some plugins already installed, but every time I run my container, the plugins are not there. It's like something removes the plugins from /opt/sonarqube/extensions/plugins and copy the bundled-plugins there.

My Dockerfile

FROM sonarqube

ENV SONARQUBE_HOME /opt/sonarqube

RUN wget "http://downloads.sonarsource.com/plugins/org/codehaus/sonar-plugins/sonar-scm-git-plugin/1.1/sonar-scm-git-plugin-1.1.jar" \
    && wget "https://github.com/SonarSource/sonar-java/releases/download/3.12-RC2/sonar-java-plugin-3.12-build4634.jar" \
    && wget "https://github.com/SonarSource/sonar-github/releases/download/1.1-M9/sonar-github-plugin-1.1-SNAPSHOT.jar" \
    && wget "https://github.com/SonarSource/sonar-auth-github/releases/download/1.0-RC1/sonar-auth-github-plugin-1.0-SNAPSHOT.jar" \
    && wget "https://github.com/QualInsight/qualinsight-plugins-sonarqube-badges/releases/download/qualinsight-plugins-sonarqube-badges-1.2.1/qualinsight-sonarqube-badges-1.2.1.jar" \
    && mv *.jar $SONARQUBE_HOME/extensions/plugins \
    && ls -lah $SONARQUBE_HOME/extensions/plugins

I tried listing the folder, and it lists my desired plugins. But if I list the same folder after I started the container, they are gone.

I've also tried removing the bundled-plugins with no luck.

Any ideas?

like image 313
Jose Armesto Avatar asked Apr 02 '16 18:04

Jose Armesto


3 Answers

Before SonarQube 5.6, plugins are stored in a volume, so the appropriate command is (after starting the sonarqube container):

wget https://sonarsource.bintray.com/Distribution/sonar-auth-github-plugin/sonar-auth-github-plugin-1.2.jar -P `docker inspect -f '{{ (index .Mounts 1).Source }}' sonarqube`/plugins
docker restart sonarqube
like image 61
thSoft Avatar answered Oct 18 '22 22:10

thSoft


Note the accepted answer is no longer true. It should work if you directly use recent parent sonarqube image. So if the Dockerfile metioned in the question does not work, you have a different problem.

See commit 80366e3419d698b4bba4447f153418ef64b3b705 for more info.

Remove volume for "conf", "logs" and "extensions" directories Explicit declaration of volume is appropriate only for data stored by application, volume for configurable things is almost never appropriate (see docker-library/official-images#2437).

This reverts commit 69fca2e. And additionally removes declaration of volume for "extensions" directory.

like image 33
Stan Prokop Avatar answered Oct 18 '22 22:10

Stan Prokop


The Sonarqube image uses a volume for the /extensions/ directory, which results in the files in that directory not being stored in the image's filesystem; see the Dockerfile

To package those extensions in your image, you need them outside of that directory, and copy those files to the /extensions/ in an entrypoint script, or store your plugins in a separate image, and mount those plugins as a volume when running the image; you can find an example doing that here; https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md

like image 27
thaJeztah Avatar answered Oct 18 '22 23:10

thaJeztah