Sign inSign up

ciandtsoftware/sonar

By ciandtsoftware

Updated over 8 years ago

Containerized solution for SonarQube with pre-loaded plugins and scripts for easy deploy.

Image
0

1.3K

ciandtsoftware/sonar repository overview

CI&T SonarQube Docker base image

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.


SonarQube Plugins

These are the plugins bundled.


Quick Start

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

CI&T scripts

There are available scripts to help customize SonarQube container:

  • configure-https
  • configure-ldap

Scripts are composed by two parts;

  • one executable file script-name.sh
  • one variables file script-name.env

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.


Running standalone

The simplest way of running the container without any modification

docker run ciandtsoftware/sonar:5.4

Customizing

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

Running in Docker-Compose

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;

conf/sonar.local.env
### 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
app/sonar/Dockerfile
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
docker-compose.yml
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/


User Feedback

Issues

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.

Contributing

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.

Documentation

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

Tag summary

Content type

Image

Digest

Size

504.2 MB

Last updated

over 8 years ago

docker pull ciandtsoftware/sonar