This docker container runs SonarQube and allows for linking a SQL database container (MySQL, PostgreSQL, MSSQL, or Oracle). You can also use an external SQL database or the embedded H2 database by setting the appropriate configuration variables.
- Docker
- Internet Access
git clone https://github.com/InfoSec812/sonarqube.git
cd sonarqube
docker build -t sonarqube ./By default, SonarQube supports PostgreSQL, Oracle, MSSQL, MySQL, and an embedded H2 database. You should be able to use any database which has a JDBC driver, but that would require customization of this container.
- Install docker-compose
- Download the docker-compose.yml file and save it as docker-compose.yml
- Edit the docker-compose.yml file to meet your environment's needs
- Start the container by running
docker-compose up -dIn most cases, upgrading from one version of this container to the next consists of:
- Stop the container
- Delete <DATA_DIR>/data/es directory
- Pull the new version of the container
- Start the new container
- Browse to http(s)://yourserver/upgrade
- Follow upgrade instructions
You may need to adjust the URL above depending on your configuration. Also, upgrading plugins may be required.
In order to install/upgrade plugins you need to restart the SonarQube service. You can do so without having to restart the container if desired. Use the docker exec command to enter the running container and then issue a kill -9 command to force supervisord to restart the service.
EXAMPLE:
$ docker ps | grep sonar
5dc3df48b34c infosec812/sonarqube:5.0.1 "/bin/sh -c /usr/bin 14 minutes ago Up 14 minutes 0.0.0.0:9000->9000/tcp sonarqube_sonarqube_1
$ docker exec -i -t sonarqube_sonarqube_1 /bin/bash
$ ps ax | grep java
66 ? Sl 0:01 java -Djava.awt.headless=true -Xms3m -Xmx32m -Djava.library.path=./lib -classpath ../../lib/jsw/wrapper-3.2.3.jar:../../lib/sonar-application-5.0.1.jar -Dwrapper.key=SUsO34i7qsG0udi_ -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=64 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp org.sonar.application.App
91 ? Sl 0:41 /usr/java/jdk1.8.0_20/jre/bin/java -Djava.awt.headless=true -Xmx1G -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/data/temp -cp ./lib/common/*:./lib/search/* org.sonar.search.SearchServer /tmp/sq-process3534710488578140315properties
169 ? Sl 1:08 /usr/java/jdk1.8.0_20/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false -Djruby.compile.invokedynamic=false -Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true -Djava.io.tmpdir=/data/temp -cp ./lib/common/*:./lib/server/*:/opt/sonar/lib/jdbc/postgresql/postgresql-9.3-1101-jdbc4.jar org.sonar.server.app.WebServer /tmp/sq-process3177121203749324429properties
303 ? S+ 0:00 grep --color=auto java
$ kill -9 66 91 169
$ supervisorctl stop sonarqube
$ supervisorctl start sonarqube
$ exitNone of the options below are 'required', but without some of them, the data stored will be lost every time the container is restarted. All default values are listed in parenthesis.
- SONAR_CONTEXT (/)
- The context path for the web application (Defaults to '/')
- SONAR_WEB_JAVA_OPTS (-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError)
- The JAVA_OPTS for the web application
- SONAR_WEB_ADDL_OPTS (NULL)
- Uses the default or provided JAVA_OPTS for the web application and appends these
- SONAR_WEB_PORT (9000)
- Port on which the web application will listen for incoming requests
- SONAR_WEB_MAX_THREADS (50)
- Maximum number of threads for the web application
- SONAR_WEB_MIN_THREADS (5)
- Minimum number of threads for the web application
- SONAR_WEB_QUEUE (25)
- Maximum number of queued requests for the web application
- SONAR_ACCESS_LOGS (NULL/Disabled)
- Enable HTTP access logs
- SONAR_SEARCH_JAVA_OPTS (-Xmx1G -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError)
- JAVA_OPTS for the Elastic Search application
- SONAR_SEARCH_ADDL_OPTS (NULL/Disabled)
- Uses the default or provided JAVA_OPTS for Elastic Search and appends these
- SONAR_SEARCH_PORT (9001)
- The port on which Elastic Search should listen for connections
- SONAR_DISABLE_UPDATES (NULL/Enabled)
- Disable SonarSource update checking
- SONAR_PROXY_HOST (NULL/Disabled)
- HTTP Proxy host for accessing the Internet
- SONAR_PROXY_PORT (NULL/Disabled)
- HTTP Proxy host for accessing the Internet
- SONAR_SOCKS_PROXY_HOST (NULL/Disabled)
- SOCKS Proxy host for accessing the Internet
- SONAR_SOCKS_PROXY_PORT (NULL/Disabled)
- SOCKS Proxy host for accessing the Internet
- SONAR_PROXY_NTLM_DOMAIN (NULL/Disabled)
- If set, the NTLM domain to use to authenticate to an NTLM authenticated proxy server
- SONAR_PROXY_USER (NULL/Disabled)
- The username with which to authenticate to the proxy
- SONAR_PROXY_PASS (NULL/Disabled)
- The password with which to authenticate to the proxy
- SONAR_LOG_LEVEL (NONE)
- The logging level (one of NONE, BASIC, FULL)
- SONAR_EXPOSE_ELASTIC_SEARCH (NULL/Disabled)
- The port on which Elastic Search should allow HTTP access
- DB_HOST (127.0.0.1)
- The host which runs the database for SonarQube
- DB_PORT (9092)
- The port on which the database listens for connections
- DB_NAME (sonar)
- The name of the database which SonarQube will use
- DB_USER (sonar)
- The username with which to authenticate to the database
- DB_PASS (sonar)
- The password with which to authenticate to the database
- DB_TYPE (embedded)
- The type of database which SonarQube will use (One of embedded,h2,postgresql,mysql,oracle,sqlserver)
- SONAR_DB_MAX_ACTIVE (50)
- Maximum number of db connections allowed
- SONAR_DB_MAX_IDLE (5)
- Maximum number of idle DB connections
- SONAR_DB_MIN_IDLE (2)
- Minimum number of spare idle DB connections
- SONAR_DB_MAX_WAIT (5000)
- Maximum amount of time to wait for a database operation (in milliseconds)
- SONAR_DB_MIN_EVICT (600000)
- Minimum time a connection must be idle before being considered for eviction from the connection pool (in milliseconds)
- SONAR_DB_EVICT_INTERVAL (30000)
- The interval at which the connection pool will consider evicting idle connections (in milliseconds)
- SONAR_DATA_DIR (/data)
- The path to the mounted docker volume where persistent data should be stored