Created
November 19, 2018 16:40
-
-
Save gtpgi/37c4ec0fa2e35b6a640c5b1f357a7dac to your computer and use it in GitHub Desktop.
Dockerfile and run script to build a Docker image for SonarQube 7.4 Developer Edition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SonarSource did not make official Docker images for SonarQube 7.1 and above (as of 2018-11-20) | |
# This Dockerfile will build SonarQube 7.4 Developer Edition | |
# Based on https://github.com/SonarSource/docker-sonarqube/blob/5d738964cc4b857ca5b399d6f0bb626b6710bac6/7.1/Dockerfile | |
FROM openjdk:8 | |
ENV SONAR_VERSION=7.4 \ | |
SONARQUBE_HOME=/opt/sonarqube \ | |
# Database configuration | |
# Defaults to using H2 | |
SONARQUBE_JDBC_USERNAME=sonar \ | |
SONARQUBE_JDBC_PASSWORD=sonar \ | |
SONARQUBE_JDBC_URL= | |
# Http port | |
EXPOSE 9000 | |
RUN groupadd -r sonarqube && useradd -r -g sonarqube sonarqube | |
# grab gosu for easy step-down from root | |
RUN set -x \ | |
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" \ | |
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture).asc" \ | |
&& export GNUPGHOME="$(mktemp -d)" \ | |
&& gpg --keyserver keyserver.ubuntu.com --recv-keys 0x036a9c25bf357dd4 \ | |
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ | |
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ | |
&& chmod +x /usr/local/bin/gosu \ | |
&& gosu nobody true | |
RUN set -x \ | |
&& gpg --keyserver keyserver.ubuntu.com --recv-keys 0xcfca4a29d26468de \ | |
&& cd /opt \ | |
&& curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-developer/sonarqube-developer-$SONAR_VERSION.zip \ | |
&& curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-developer/sonarqube-developer-$SONAR_VERSION.zip.asc \ | |
&& gpg --batch --verify sonarqube.zip.asc sonarqube.zip \ | |
&& unzip sonarqube.zip \ | |
&& mv sonarqube-$SONAR_VERSION sonarqube \ | |
&& chown -R sonarqube:sonarqube sonarqube \ | |
&& rm sonarqube.zip* \ | |
&& rm -rf $SONARQUBE_HOME/bin/* | |
VOLUME "$SONARQUBE_HOME/data" | |
WORKDIR $SONARQUBE_HOME | |
COPY run.sh $SONARQUBE_HOME/bin/ | |
ENTRYPOINT ["./bin/run.sh"] | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ "${1:0:1}" != '-' ]; then | |
exec "$@" | |
fi | |
chown -R sonarqube:sonarqube $SONARQUBE_HOME | |
exec gosu sonarqube \ | |
java -jar lib/sonar-application-$SONAR_VERSION.jar \ | |
-Dsonar.log.console=true \ | |
-Dsonar.jdbc.username="$SONARQUBE_JDBC_USERNAME" \ | |
-Dsonar.jdbc.password="$SONARQUBE_JDBC_PASSWORD" \ | |
-Dsonar.jdbc.url="$SONARQUBE_JDBC_URL" \ | |
-Dsonar.web.javaAdditionalOpts="$SONARQUBE_WEB_JVM_OPTS -Djava.security.egd=file:/dev/./urandom" \ | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I apply the dev license key when using this docker image to unlock Dev edition?
How can I add custom .jar files to the image, such as code scan?