https://github.com/inushin/dockersonarqubesonarscanner
This is a complete config for SonarQube with Docker and a custom script for launching SonarScanner.
https://github.com/inushin/dockersonarqubesonarscanner
docker docker-compose sonarqube sonarscanner
Last synced: about 1 month ago
JSON representation
This is a complete config for SonarQube with Docker and a custom script for launching SonarScanner.
- Host: GitHub
- URL: https://github.com/inushin/dockersonarqubesonarscanner
- Owner: Inushin
- Created: 2024-06-20T09:47:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-21T19:53:28.000Z (about 1 year ago)
- Last Synced: 2025-03-28T22:13:10.472Z (8 months ago)
- Topics: docker, docker-compose, sonarqube, sonarscanner
- Language: Shell
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π³ Docker + SonarQube + SonarScanner Bash π³

If you find this useful, remember about giving a start β to this repo or share it π
## Description π

This is a complete config for SonarQube with Docker and a custom script for launching SonarScanner.
It is composed by 2 containers:
- `sonarqube`
- `postgres`
## Installation β¨

0. You need **Docker** and **Docker Compose** where you are going to launch this so, if you do not have it... click [HERE](https://github.com/Inushin/dockerSonarQubeSonarScanner#installing-docker-and-docker-compose-) or go to the end of this `.md` ^^
1. Clone this rep.
2. Edit `docker-compose.yml` with the information you want.
3. Check you systems Max Virtual Memory limit. With Linux, by default, it is sett to 65530. It should be increase to at leasr 262144:
````bash
sudo sysctl -w vm.max_map_count=262144
````
4. Run `docker compose up` π.
5. After running SonarQube and PostgreSQL, all the folders should have been filled with the data if it exists during the instalation. For future steps, give permision to the volumes content.
5. Check that the 2 containers are deployed:
```yaml
sonarqube:9.7.1-community "/opt/sonarqube/bin/β¦" running 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp sonarqube
postgres:alpine3.14 "docker-entrypoint.sβ¦" running 5432/tcp postgresql
````
6. With the container running correctly, log inside the server with your browser `http://localhost:9000` and update your account password.
7. **IMPORTANT SECURITY MODIFICATION NOT RECOMENDED FOR PRODUCTION OR REMOTE SERVER SONARQUBE** - Go to `Administration -> Security` and disable `Force user authentication`.
8. Now, with the user authentication" disabled, we can execute `sonar-scanner.sh`. REMEMBER to update this script with the info of the project you want to scann and run `./sonar-scanner.sh`.
9. When the scanner has finished, you can go to `http://localhost:9000` and check the results.
## Docker's useful commands π

- Run Docker Compose: `docker compose up -d` / `docker compose up`
- Check Docker Compose's volumens status: `docker compose ps -a` / `docker compose ps`
- Check Docker's images: `docker images -a`
- Remove Docker's images: `docker rmi -f imageID1 imageID2 ...` (-f = force)
- Enter to a Docker's volumen: `docker compose exec VolumenID sh` / `docker compose exec VolumenID bash`
- Copy a file to the docker we want to: `docker cp file docker_id:/dir`
- Remove all dangling (not tagged or associated with a container) containers, volumes, networks and images: `docker system prune`
- Remove all unused containers and images with at least one container associated to them: `docker system prune -a`
- Shows all unused local images: `docker images ls -f dangling=true`
- Shows all unused local volumes: `docker volume ls -f dangling=true`
- Remove all local volumes not used by at least one container: `docker volume prune`
## Installing Docker and Docker Compose π

**Adjust the installation to your OS. Here you have the one for a VPS with Debian 11**
- Docker and Docker Compose installation
1. Update the `apt` package index and install packages to allow `apt` to use a repository over HTTPS:
```yaml
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
```
2. Add Dockerβs official GPG key:
```yaml
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
```
3. Use the following command to set up the repository:
```yaml
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
```
4. Starts Docker's service each time you run the SO: `sudo systemctl enable docker`
```yaml
sudo apt-get update
```
5. Install Docker Engine, containerd, and Docker Compose. This will install the latest version:
```yaml
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
```
6. Give permissions to the desired user by adding it the `docker` group:
```yaml
usermod -aG docker $USER
```
7. Check the version and the installation: `docker compose version` `docker --version`
## β Feedback and bugs π
If you find any bug or just want to give your feedback (remember the β ^^), **Feel free to do it**. I am, like you, constantly learning and things change so quickly that... no one knows ^^
## Version control π
- [v1.0 - Current](https://github.com/Inushin/dockerSonarQubeSonarScanner/tree/v1.0) - Creation of the rep with the config finished - 20/06/2024