-
-
Save agusmakmun/9cc44f78fb3bc9e585a3782b799767bd to your computer and use it in GitHub Desktop.
Revisions
-
Swiss-Mac-User revised this gist
Aug 10, 2022 . 1 changed file with 16 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,23 @@ # Install and run SonarQube on Docker ## Installing SonarQube ### On Intel based Macs (x86_64) #### Install the Docker image from Docker Hub `docker pull sonarqube` #### Start the x86_64 SonarQube Server `docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest` ### On ARM based Macs (Apple Silicon) #### Install the Docker image from a custom build 1. `mkdir ~/Downloads/sonarqube-arm` 2. `git clone https://github.com/SonarSource/docker-sonarqube ~/Downloads/sonarqube-arm/` 3. `docker build -t sonarqube-arm ~/Downloads/sonarqube-arm/docker-sonarqube/9/community` #### Start the compiled ARM SonarQube Server `docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube-arm:latest` ## Open SonarQube in the webbrowser [http://localhost:9000](http://localhost:9000) -
Swiss-Mac-User created this gist
May 29, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ # Docker setup ## Install the Docker UI application for macOS `brew install docker --cask` ## Open the Docker.app from /Applications/Docker.app ## Go to the Docker Dashboard Wait until the "Docker Dashboard starting…"-message disappears (= Setup complete) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # «SonarScanner» - SonarQube Code Analyser ## Install the SonarScanner (SonarQube Code Analyser) `brew install sonar-scanner` ## Add the SonarScanner bin-directory to $PATH Find the SonarScanner `bin`-directory (can be taken from the homebrew package installation information) * Should be something like: `/usr/local/Cellar/sonar-scanner/4.7.0.2747/libexec/bin` Edit the current User's bash source `nano ~/.zshrc` Add these line somewhere: ```bash # === SonarQube === # NOTE: sonar-scanner Version in dir-path may change! export PATH=/usr/local/Cellar/sonar-scanner/4.7.0.2747/libexec/bin:$PATH ``` Save and close. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ # Installing SonarQube (on Docker) ## Install the Docker image `docker pull sonarqube` ## Start the SonarQube Server `docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest` ## Open SonarQube in the webbrowser [http://localhost:9000](http://localhost:9000) ## Login with default credentials * User: `admin` * Pass: `admin` …and as instructed, set a new password. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ # Add a code project to SonarQube On the [SonarQube Dashboard](http://localhost:9000/dashboard)… 1. Click on «Create a project manually» 2. Fill-in a project name and project key * NOTE: you will need this project key later! 3. Click on «Analyze your project locally» 4. Fill-in a Token name * NOTE: copy the generated Token, you will need this later! 5. Click on «Other (for JS, TS, Go, Python, PHP, ...)» and select your OS preferences 6. Follow the on-screen instructions ## Add a SonarScanner project configuration-file to the desired code project 1. Go to the intended project directory 2. Create a new file named `sonar-project.properties` 3. Add and modify the following contents to the sonar-project file: ``` # must be unique in a given SonarQube instance sonar.projectKey=my_project_key_as_defined_on_sonarqube_web # --- optional properties --- # defaults to project key #sonar.projectName=My project # defaults to 'not provided' #sonar.projectVersion=1.0 # Path is relative to the sonar-project.properties file. Defaults to . #sonar.sources=. #sonar.sources=src # path to test source directories (optional) #sonar.tests=tests # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 ``` # Run the SonarScanner Code Analysis for this project HINT: You can copy this command from the last step in the SonarQube project setup! ``` sonar-scanner \ -Dsonar.projectKey=my_project_key_as_defined_on_sonarqube_web \ -Dsonar.sources=. \ -Dsonar.host.url=http://localhost:9000 \ -Dsonar.login=my_sonarqube_project_token ``` …or using a simplified command, which reads other settings from the sonar-project file: `sonar-scanner -Dsonar.login=my_sonarqube_project_token` ## DONE - see the results on the SonarQube web dashboard [http://localhost:9000/dashboard](http://localhost:9000/dashboard) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ # Export and transfer the SonarQube Docker container E.g. to be used with same settings on another Mac. * Make sure the Docker.app is running and the Desktop was started! ## Stop the server (if running) `docker stop sonarqube` ## Create an image file from the Docker container `docker commit sonarqube mysonarqube` * NOTE: this can take a moment (or two)… Save the image file to any user accessible folder in macOS Finder e.g. to the «Downloads»-folder, using: * Default Docker file (tar, uncompressed):<br>`docker save mysonarqube -o ~/Downloads/SonarQube-DockerBackup.tar` * Gzipped (compressed) Docker file:<br>`docker save mysonarqube | gzip > ~/Downloads/SonarQube-DockerBackup.tar.gz` ## Transfer the Docker container file to where you need it… # Import a Docker container file E.g. on the second Mac. ## Start the Docker.app, if not running… ## Load the Docker container file `docker load < /path/to/SonarQube-DockerBackup.tar.gz` ``` Loading layer [==================================================>] 337.9MB/337.9MB Loaded image: mysonarqube:latest ``` * NOTE: this can take a moment (or two)… # Run the imported SonarQube Docker image NOTE: must use the image file reference, instead of `sonarqube:latest`! `docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 mysonarqube:latest` ## DONE - see the results on the SonarQube web dashboard [http://localhost:9000/dashboard](http://localhost:9000/dashboard) * NOTE: may take a moment (or two) until accessible…