Reputation: 92367
I want to (un)install some SonarQube plug-ins and load a quality profile xml file all within a Docker container.
My approach so far is this (part of my Dockerfile):
RUN set -x \
&& apk add --no-cache unzip curl \
&& curl --tlsv1 -o sonarqube.zip -fSL https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.3.1.zip \
&& unzip sonarqube.zip \
&& mv sonarqube-6.3.1 /opt/sonarqube \
RUN java -jar /opt/sonarqube/lib/sonar-application-6.3.1.jar &
RUN curl -X POST -u admin:admin http://localhost:9000/api/plugins/uninstall?key=csharp
ENTRYPOINT java -jar /opt/sonarqube/lib/sonar-application-6.3.1.jar
I tried to start SonarQube in a separate process, as you can see:
java -jar /opt/sonarqube/lib/sonar-application-6.3.1.jar
But the next command, curl -X POST ...
is failing, probably because the sonar server isn't up and running at this moment:
The command '/bin/sh -c curl -X POST -u admin:admin http://localhost:9000/api/plugins/uninstall?key=csharp' returned a non-zero code: 7
However, if I don't start a new process for SonarQube (removing &
at the end of the line), the docker build keeps hanging telling me that SonarQube is up.
How can I configure SonarQube in a Dockerfile? And what is the best way to stop it at the end of the configuration (to avoid conflicts with the entrypoint)?
Upvotes: 3
Views: 7337
Reputation: 2167
Very comprehensive documentation is here: Docker - sonarqube Especially best practices are mentionned in section Advance Configuration.
When you need additional plugins, the best practice is to mount dedicated directory, where plugins are located. This saves you maintenance of the docker images, when updating any plugin.
There is also hint, that you can externalize configuration directory, what will help you to manage configuration.
Upvotes: 1