DEV Community

Cover image for SonarQube Community Edition in a Docker Container on Mac M1
Kevin Lupera
Kevin Lupera

Posted on

SonarQube Community Edition in a Docker Container on Mac M1

Requirements

  • Docker

If you don't already have docker installed, this link has more information for Mac and Windows. docker

Start container use:

I am using a Mac with an Apple M1 chip, so I was successful using this docker-compose:

  1. Clone repo https://github.com/kevinlupera/SonarQube-docker-compose
  2. Move into repository cd SonarQube-docker-compose
  3. Start Containers docker-compose up

Stop container use:

Control + C in this terminal or docker-compose down

Scanning Your Code

Before scanning your code with SonarQube, you need to install SonarScanner on the operating system where your project is located.

For Mac, you can follow these steps:
brew install sonar-scanner

Once you have installed the SonarScanner, you can proceed with the following steps:

  1. Go to the SonarQube URL (http://localhost:9000).
  2. Log in to your SonarQube instance using the default credentials (login/pwd: admin).
  3. Navigate to the Projects page.
  4. Click on the “Create Project” button and choose the “Manually” option.
  5. Fill in the required fields with relevant project information.
  6. Generate a token and click “Continue.”
  7. Select the appropriate option for your project’s language (e.g., “Other” for JS, TS, Go, Python, PHP).
  8. Choose your operating system.
  9. You will see a code snippet that represents the command to run the scanner. It will look similar to the following:
sonar-scanner \
-Dsonar.projectKey=PROJECTKEY\
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=TOKEN
Enter fullscreen mode Exit fullscreen mode

Once the analysis is complete, return to the SonarQube server.

Top comments (0)