Containerized solution for SonarQube with pre-loaded plugins and scripts for easy deploy.
1.3K
This Docker image intends to be a containerized baseline solution for SonarQube with pre-loaded plugins and scripts for easy deploy and management.
The source code is available under GPLv3 at Bitbucket in this link.
Basically, this image utilizes SonarQube official Docker image as a source, then copy plugins (listed below), add scripts and configure it to run only HTTPS with a self-signed SSL certificate.
These are the plugins bundled.
| Plugin | Version |
|---|---|
| Android | 1.1 |
| Bitbucket Authenticatior | 1.0 |
| C# | 5.5.0.479 |
| CSS | 2.3 |
| Github | 1.3 |
| Github Authenticatior | 1.3 |
| Java | 4.2.1 |
| Javascript | 2.18 |
| LDAP | 2.1 |
| PhP | 2.9.1 |
| Resharper | 2.0 |
| Stylecop | 1.1 |
| Web-frontend-scss | 2.0 |
| Widget-lab | 1.8.1 |
Download the image
docker pull ciandtsoftware/sonar:5.4
Run a container
docker run \
--name \
myContainer \
--detach \
ciandtsoftware/sonar:5.4
Check running containers
docker ps --all
There are available scripts to help customize SonarQube container:
Scripts are composed by two parts;
The script-name .env contains the variables that script-name .sh requires to perform its task.
All scripts are located inside folder /root/ciandt and must be declared in the Makefile. Thus, it is easy to run any of them.
Furthermore, it is possible to merge all the environment variables together and use an env_file approach when running Docker, it is highly recommended! More information about it can be found here.
Since configure-https variables are already shiped in the image, you can run the container and compare environment variables with the ones in configure-https.env by running:
export
Then you can run the commands to see the outcome:
cd /root/ciandt
make configure-https
It will gather required variables from environment, execute and produce the according output.
The simplest way of running the container without any modification
docker run ciandtsoftware/sonar:5.4
As intended, you can take advantage from this image to build your own and already configure everything that a project requires.
Just to have an example, a Dockerfile sample downstream this image and configuring SonarQube to use LDAP (Microsoft Active Directory) authentication.
FROM ciandtsoftware/sonar:5.4
## configure-ldap
# define environment variables
ENV LDAP_REALM=contoso.local
ENV LDAP_SERVER=server.contoso.local
ENV LDAP_PORT=3268
ENV [email protected]
ENV LDAP_PASSWORD=MyStrongPassword1
# configure Sonar LDAP
RUN cd /root/ciandt && \
make configure-ldap
Since a project is not going to use solely SonarQube, it may need a Docker-Compose file.
Just to exercise, follow an example of SonarQube running behind a Nginx proxy. Create a new folder and fill with these 3 files and respective folders;
### SonarQube official environment variables
# database
SONARQUBE_JDBC_USERNAME=sonar
SONARQUBE_JDBC_PASSWORD=sonar
SONARQUBE_JDBC_URL=jdbc:h2:tcp://localhost:9092/sonar
## Nginx proxy configuration
# https://hub.docker.com/r/jwilder/nginx-proxy/
VIRTUAL_HOST=sonar.local
VIRTUAL_PORT=9000
VIRTUAL_PROTO=https
FROM ciandtsoftware/sonar:5.4
## configure-ldap
# define environment variables
ENV LDAP_REALM=contoso.local
ENV LDAP_SERVER=server.contoso.local
ENV LDAP_PORT=3268
ENV [email protected]
ENV LDAP_PASSWORD=MyStrongPassword1
# configure Sonar LDAP
RUN cd /root/ciandt && \
make configure-ldap
sonar:
build: ./sonar
container_name: sonar
env_file: ../conf/sonar.local.env
nginx:
image: jwilder/nginx-proxy:latest
container_name: nginx
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
ports:
- "80:80"
- "443:443"
Then just spin-up your Docker-Compose with the command:
docker-compose up -d
Inspect Nginx container IP address:
docker inspect --format \
"{{.NetworkSettings.Networks.bridge.IPAddress }}" \
"nginx"
Use the IP address to update hosts file. Let's suppose that was 172.17.0.2.
Then, add an entry to /etc/hosts.
172.17.0.2 sonar.local
And now, try to access in the browser
Voilà! Your project now have Nginx and SonarQube up and running. \o/
If you have problems, bugs, issues with or questions about this, please reach us in Github issues page.
Needless to say, please do a little research before posting.
We gladly invite you to contribute fixes, new features, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
There are two parts of the documentation.
First, in the master branch, is this README.MD. It explains how this little scripts framework work and it is published on Github page.
Second, in each image version there is an additional README.MD file that explains how to use that specific Docker image version itself. Latest version is always the one seen on Docker Hub page.
We strongly encourage reading both!
Happy coding, enjoy!!
"We develop people before we develop software" - Cesar Gon, CEO
Content type
Image
Digest
Size
504.2 MB
Last updated
over 8 years ago
docker pull ciandtsoftware/sonar