SonarQube is a top-tier source code quality management application that provides comprehensive code analysis and support for 17 programming languages. It is the preferred solution for static code analysis and code coverage, and is widely used by developers and organizations.
This article provides a step-by-step guide to setting up SonarQube with Docker Compose, integrated with a PostgreSQL database and an Nginx proxy to redirect traffic to port 80 on your domain.
Finally, we will configure SonarQube authentication and authorization to an LDAP server by configuring the appropriate values in <SONARQUBE_HOME>/conf/sonar.properties.
Prerequisites
Before we start, ensure you have the following:
We may move further with the system settings now.
System Configuration
SonarQube needs to make some system adjustments because it uses Elasticsearch to store its indices in an MMapFS directory. You must ensure that:
Use the steps provided below according to your operating system:
For Red Hat, CentOS, or Amazon Linux
For Ubuntu or Debian
Installation
In order to establish our services, we require a docker-compose.yaml file:
What Do We Have Here?
Three services (SonarQube, PostgreSQL, and Nginx) are included in this compose file.
To redirect the traffic from localhost:9000 to your domain on port 80, it is necessary to create an nginx.conf file. Make sure that this file is located in the same directory as the docker-compose.yaml file:
Running the Setup
Run the following command to start the setup:
Docker Compose orchestrates and executes your complete application. To access SonarQube, use the domain indicated in your nginx.conf file, which is yourdomain.com
LDAP Configuration
Integrating LDAP (Lightweight Directory Access Protocol) with SonarQube is essential for firms seeking to manage user authentication and authorization centrally. LDAP integration enables the utilization of an already established LDAP directory, such as Active Directory, for the purpose of managing users. This streamlines administration by ensuring that there is just one authoritative source for user data.
The main setup for LDAP integration in SonarQube is performed via the sonar.properties file. This file is usually located in <SONARQUBE_HOME>/conf/sonar.properties
To implement the new configuration, restart the SonarQube server after saving the changes to the sonar.properties file.
Accessing SonarQube
Verify the LDAP configuration by attempting to log in with an LDAP user account after SonarQube has restarted. Ensure that the user attributes, such as email and name, are accurately populated from the LDAP directory.