{"id":16532813,"url":"https://github.com/mjstealey/sonarqube-ce-docker","last_synced_at":"2025-06-30T12:36:58.288Z","repository":{"id":93420676,"uuid":"451263626","full_name":"mjstealey/sonarqube-ce-docker","owner":"mjstealey","description":"SonarQube LTS / PostgreSQL / Nginx - Orchestrated with Docker Compose","archived":false,"fork":false,"pushed_at":"2023-03-03T18:24:56.000Z","size":7349,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T14:21:18.396Z","etag":null,"topics":["docker","docker-compose","letsencrypt","nginx","postgres","sonarqube"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjstealey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-24T00:04:15.000Z","updated_at":"2024-06-15T01:42:35.000Z","dependencies_parsed_at":"2023-03-22T12:32:10.569Z","dependency_job_id":null,"html_url":"https://github.com/mjstealey/sonarqube-ce-docker","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"329737ce62f009b01c558c75feb4960f6eaae730"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjstealey%2Fsonarqube-ce-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjstealey%2Fsonarqube-ce-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjstealey%2Fsonarqube-ce-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjstealey%2Fsonarqube-ce-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjstealey","download_url":"https://codeload.github.com/mjstealey/sonarqube-ce-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248252718,"owners_count":21072701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","letsencrypt","nginx","postgres","sonarqube"],"created_at":"2024-10-11T18:13:29.897Z","updated_at":"2025-04-10T16:33:14.087Z","avatar_url":"https://github.com/mjstealey.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# SonarQube CE (Community Edition) - Docker\n\nNotes on [SonarQube Community Edition](https://www.sonarqube.org/downloads/) as a docker deployment orchestrated by Docker Compose.\n\n- Use the LTS version of SonarQube (v8.9)\n- Use PostgreSQL as the database (v14)\n- Use Nginx as the web server (v1)\n- Include self-signed SSL certificate ([Let's Encrypt localhost](https://letsencrypt.org/docs/certificates-for-localhost/) format)\n\n**DISCLAIMER: The code herein may not be up to date nor compliant with the most recent package and/or security notices. The frequency at which this code is reviewed and updated is based solely on the lifecycle of the project for which it was written to support, and is not actively maintained outside of that scope. Use at your own risk.**\n\n## Table of contents\n\n- [Overview](#overview)\n    - [Host requirements](#hostreqts)\n- [Configuration](#config)\n- [Deploy](#deploy)\n- [Example: Manually add a project](#example)\n    - [Add a project](#addproject)\n    - [Execute the scanner](#scanner)\n- [GitHub integration](#github)\n- [Jenkins integration](#jenkins)\n- [Teardown](#teardown)\n- [References](#references)\n- [Notes](#notes)\n\n## \u003ca name=\"overview\"\u003e\u003c/a\u003eOverview\n\nDetails for the installation and usage of the Docker based SonarQube image. \n\n- Ref: [https://hub.docker.com/_/sonarqube/](https://hub.docker.com/_/sonarqube/)\n\n![](./imgs/SQ-instance-components.png)\n\n### \u003ca name=\"hostreqts\"\u003e\u003c/a\u003eHost requirements\n\n- Because SonarQube uses an embedded Elasticsearch, make sure that your Docker host configuration complies with the Elasticsearch production mode requirements and File Descriptors configuration.\n- For example, on Linux, you can set the recommended values for the current session by running the following commands as root on the host:\n\n    As root\n    \n    ```console\n    sysctl -w vm.max_map_count=524288\n    sysctl -w fs.file-max=131072\n    ulimit -n 131072\n    ulimit -u 8192\n    ```\n\n## \u003ca name=\"config\"\u003e\u003c/a\u003eConfiguration\n\nCopy the `env.template` file as `.env` and populate according to your environment\n\n```ini\n# docker-compose environment file\n#\n# When you set the same environment variable in multiple files,\n# here’s the priority used by Compose to choose which value to use:\n#\n#  1. Compose file\n#  2. Shell environment variables\n#  3. Environment file\n#  4. Dockerfile\n#  5. Variable is not defined\n\n# SonarQube Settings\nexport SONAR_JDBC_URL=jdbc:postgresql://database:5432/sonar\nexport SONAR_JDBC_USERNAME=sonar\nexport SONAR_JDBC_PASSWORD=sonar\n\n# PostgreSQL Settings\nexport POSTGRES_USER=sonar\nexport POSTGRES_PASSWORD=sonar\n\n# Nginx Settings\nexport NGINX_CONF=./nginx/default.conf\nexport NGINX_SSL_CERTS=./ssl\nexport NGINX_LOGS=./logs/nginx\n\n# User Settings\n# TBD\n```\n\nModify the `nginx/default.conf` file to match your `SERVER DOMAIN` and `PORT`\n\n```conf\nupstream sonarqube {\n    keepalive 32;\n    server ce-sonarqube:9000;    # sonarqube ip and port\n}\n\nserver {\n    listen 80;                    # Listen on port 80 for IPv4 requests\n    server_name $host;\n    return 301 https://$host:8443$request_uri; # replace '8443' with your https port\n}\n\nserver {\n    listen          443 ssl;      # Listen on port 443 for IPv4 requests\n    server_name     $host:8443;   # replace '$host:8443' with your server domain name and port\n\n    # SSL certificate - replace as required with your own trusted certificate\n    ssl_certificate /etc/ssl/fullchain.pem;\n    ssl_certificate_key /etc/ssl/privkey.pem;\n\n    # logging\n    access_log /var/log/nginx/sonar.access.log;\n    error_log /var/log/nginx/sonar.error.log;\n\n    proxy_buffers 16 64k;\n    proxy_buffer_size 128k;\n    large_client_header_buffers 4 8k;\n\n    location / {\n        proxy_pass         http://sonarqube;\n        proxy_redirect     default;\n        proxy_http_version 1.1;\n        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;\n\n        proxy_set_header   Host              $host;\n        proxy_set_header   X-Real-IP         $remote_addr;\n        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;\n        proxy_set_header   X-Forwarded-Proto $scheme;\n        proxy_set_header   X-Forwarded-Host  $host;\n        proxy_set_header   X-Forwarded-Port  8443;\n    }\n}\n```\n\n## \u003ca name=\"deploy\"\u003e\u003c/a\u003eDeploy\n\nOnce configured the containers can be brought up using Docker Compose\n\n```console\nsource .env\ndocker-compose pull\ndocker-compose up -d\n```\n\nAfter a few moments the containers should all be observed as `running`\n\n```console\n$ docker-compose ps\nNAME                COMMAND                  SERVICE             STATUS              PORTS\nce-database         \"docker-entrypoint.s…\"   database            running             5432/tcp\nce-nginx            \"/docker-entrypoint.…\"   nginx               running             0.0.0.0:8080-\u003e80/tcp, 0.0.0.0:8443-\u003e443/tcp\nce-sonarqube        \"bin/run.sh bin/sona…\"   sonarqube           running             9000/tcp\n```\n\nThe SonarQube application can be reached at the designated host and port (e.g. [https://127.0.0.1:8443]()). \n\n- **NOTE**: you will likely have to acknowledge the security risk if using the included self-signed certificate.\n\nUse the default user/pass to log in initially as the `admin` user. You will be prompted to change the password after first login.\n\n- user: **admin**\n- pass: **admin**\n\n![](./imgs/SQ-initial-page.png)\n\nOnce a new password is set you'll see the Administrator's homepage\n\n![](./imgs/SQ-admin-homepage.png)\n\n## \u003ca name=\"example\"\u003e\u003c/a\u003eExample: Manually added project\n\n### \u003ca name=\"addproject\"\u003e\u003c/a\u003eAdd a new project\n\nAdd a project manually from a local repository cloned from Github.\n\nIn the SonarQube UI:\n\n1. Create a new project\n    - From the upper right corner of the UI: `Add Project \u003e Manually`\n2. Enter values for:\n    - **Project key** (e.g. project-registry)\n    - **Display name** (e.g. project-registry)\n3. Provide a token (or generate one)\n    - **Enter a name for your token** (e.g. project-registry)\n    - This yields a token: (e.g. `8aaf4c54b6d69f85bb89c08338c30f0b9a1ac251`)\n4. Run analysis on your project\n    - **What option best describes your build?** (e.g. Python)\n    - **What is your OS?** (e.g. macOS)\n\nAt this point SonarQube will provide some information on how to execute the scanner\n\n![](./imgs/SQ-manual-project-setup.png)\n\n### \u003ca name=\"scanner\"\u003e\u003c/a\u003eExecute the Scanner from your computer\n\nWith the [sonarsource/sonar-scanner-cli](https://hub.docker.com/r/sonarsource/sonar-scanner-cli) Docker image use the information provided in the UI to run the scan\n\n```ini\nsonar-scanner \\\n  -Dsonar.projectKey=project-registry \\\n  -Dsonar.sources=. \\\n  -Dsonar.host.url=https://127.0.0.1:8443 \\\n  -Dsonar.login=8aaf4c54b6d69f85bb89c08338c30f0b9a1ac251\n```\n\nCreate a file named `sonar-project.properties` in your repository with the appropriate values\n\nExample: `sonar-project.properties` file\n\n```ini\n# --- required properties ---\n\n# must be unique in a given SonarQube instance\nsonar.projectKey=my:project\n\n\n# --- optional properties ---\n\n# defaults to project key\n#sonar.projectName=My project\n# defaults to 'not provided'\n#sonar.projectVersion=1.0\n \n# Path is relative to the sonar-project.properties file. Defaults to .\n#sonar.sources=.\n \n# Encoding of the source code. Default is default system encoding\n#sonar.sourceEncoding=UTF-8\n```\n\nPrepare the appropriate `docker run` call for the scanner.\n\n```\ndocker run \\\n    --rm \\\n    -e SONAR_HOST_URL=\"http://${SONAR_HOST_URL}\" \\\n    -e SONAR_LOGIN=\"${SONAR_LOGIN_TOKEN}\" \\\n    -v \"${SONAR_SOURCE_REPO}:/usr/src\" \\\n    sonarsource/sonar-scanner-cli\n```\n\n- **NOTE**: If executing on the same server that is running the docker based SonarQube:\n    - Use the docker-compose network (e.g. `--network=\"${SONAR_COMPOSE_NETWORK}\"`)\n    - `SONAR_HOST_URL `: connect to the `sonarqube` container by it's docker-compose name (e.g. `http://sonarqube:9000`)\n\nExample using `sonar-scanner-cli` to scan the `project-registry` code\n\n```console\nexport SONAR_HOST_URL='http://sonarqube:9000'\nexport SONAR_SOURCE_REPO=$(pwd)'/project-registry'\nexport SONAR_LOGIN_TOKEN ='8aaf4c54b6d69f85bb89c08338c30f0b9a1ac251'\nexport SONAR_COMPOSE_NETWORK='ce-sonar'\n\ndocker run \\\n    --rm \\\n    -e SONAR_HOST_URL=\"${SONAR_HOST_URL}\" \\\n    -e SONAR_LOGIN=\"${SONAR_LOGIN_TOKEN}\" \\\n    -v \"${SONAR_SOURCE_REPO}:/usr/src\" \\\n    --network=\"${SONAR_COMPOSE_NETWORK}\" \\\n    sonarsource/sonar-scanner-cli\n```\n\nIf successful there should be output similar to\n\n```console\nINFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties\nINFO: Project root configuration file: /usr/src/sonar-project.properties\nINFO: SonarScanner 4.6.2.2472\nINFO: Java 11.0.12 Alpine (64-bit)\nINFO: Linux 5.10.76-linuxkit amd64\nINFO: User cache: /opt/sonar-scanner/.sonar/cache\nINFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties\nINFO: Project root configuration file: /usr/src/sonar-project.properties\nINFO: Analyzing on SonarQube server 8.9.6\n...\nINFO: SCM Publisher SCM provider for this project is: git\nINFO: SCM Publisher 30 source files to be analyzed\nINFO: SCM Publisher 30/30 source files have been analyzed (done) | time=1393ms\nINFO: CPD Executor 6 files had no CPD blocks\nINFO: CPD Executor Calculating CPD for 26 files\nINFO: CPD Executor CPD calculation finished (done) | time=120ms\nINFO: Analysis report generated in 330ms, dir size=360 KB\nINFO: Analysis report compressed in 12768ms, zip size=128 KB\nINFO: Analysis report uploaded in 62ms\nINFO: ANALYSIS SUCCESSFUL, you can browse http://sonarqube:9000/dashboard?id=project-registry\nINFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report\nINFO: More about the report processing at http://sonarqube:9000/api/ce/task?id=AX6JMCIvWWXSLK7V_fZf\nINFO: Analysis total time: 34.960 s\nINFO: ------------------------------------------------------------------------\nINFO: EXECUTION SUCCESS\nINFO: ------------------------------------------------------------------------\nINFO: Total time: 38.645s\nINFO: Final Memory: 7M/40M\nINFO: ------------------------------------------------------------------------\n```\n\nAnd the project page will update with the results\n\n![](./imgs/SQ-manual-project-run.png)\n\n## \u003ca name=\"github\"\u003e\u003c/a\u003eGitHub integration\n\n### Step 1: Creating your GitHub App\n\n**For security reasons, make sure you're using HTTPS protocol for your URLs in your app.**\n\nSee GitHub's documentation on [creating a GitHub App](https://docs.github.com/apps/building-github-apps/creating-a-github-app/) for general information on creating your app.\n\nSpecify the following settings in your app:\n\n- **GitHub App Name** – Your app's name.\n- **Homepage URL** – You can use any URL, such as https://www.sonarqube.org/.\n- **User authorization callback URL** – Your instance's base URL. For example, https://yourinstance.sonarqube.com.\n- **Webhook UR**L – Your instance's base URL. For example, https://yourinstance.sonarqube.com.\n- Grant access for the following **Repository permissions**:\n\n    **Permission** | **Access**\n    :----------|:-----------\n    Checks\t| Read \u0026 write\n    **GitHub Enterprise**: Repository metadata | Read-only\n    **GitHub.com**: Metadata (this setting is automatically set by GitHub) | Read-only\n    Pull Requests | Read \u0026 write\n    Commit statuses | Read-only\n\n- And grant access for the following **Organization permissions**:\n\n    **Permission** | **Access**\n    :----------|:-----------\n    Members | Read-only\n    Projects | Read-only\n    \n- If setting up **GitHub Authentication**, in addition to the aforementioned Repository permissions, grant access for the following **User permissions**:\n\n    **Permission** | **Access**\n    :----------|:-----------\n    Email addresses\t| Read-only\n\n- Under \"Where can this GitHub App be installed?,\" select **Any account**.\n\n### Step 2: Installing your GitHub App in your organization\n\nNext, you need to install your GitHub App in your organizations. See GitHub's documentation on [installing GitHub Apps](https://docs.github.com/en/free-pro-team@latest/developers/apps/installing-github-apps) for more information.\n\n### Step 3: Updating your SonarQube global settings with your GitHub App information\n\nAfter you've created and installed your GitHub App, update your global SonarQube settings to finish integration and allow for the import of GitHub projects.\n\nNavigate to **Administration \u003e Configuration \u003e General Settings \u003e ALM Integrations \u003e GitHub** and specify the following settings:\n\n- **Configuration Name** (Enterprise and Data Center Edition only) – The name used to identify your GitHub configuration at the project level. Use something succinct and easily recognizable.\n- **GitHub URL** – For example, `https://github.company.com/api/v3` for GitHub Enterprise or `https://api.github.com/` for GitHub.com.\n- **GitHub App ID** – The App ID is found on your GitHub App's page on GitHub at **Settings \u003e Developer Settings \u003e GitHub Apps**.\n- **Client ID** – The Client ID is found on your GitHub App's page.\n- **Client secret** – The Client secret is found on your GitHub App's page.\n- **Private Key** – Your GitHub App's private key. You can generate a `.pem` file from your GitHub App's page under **Private keys**. Copy and paste the contents of the file here.\n\n### Step 4: Setting up GitHub authentication\n\n**If you're using Community Edition or you want to use a dedicated app for GitHub authentication, see the Creating a dedicated app for authentication section below.**\n\nTo allow users to log in with GitHub credentials, use the GitHub App that you created above (see the **Importing your GitHub repositories using a GitHub App** section for more information) and update your global SonarQube settings.\n\nTo update your global SonarQube settings:\n\nNavigate to **Administration \u003e Configuration \u003e General Settings \u003e ALM Integrations \u003e GitHub \u003e GitHub Authentication** and update the following:\n\n1. **Enabled** – set the switch to true.\n2. **Client ID** – the Client ID is found below the GitHub App ID on your GitHub App's page.\n3. **Client Secret** – the Client secret is found below the Client ID on your GitHub App's page.\nNow, from the login page, your users can connect their GitHub accounts with the new \"Log in with GitHub\" button.\n\n### Creating a dedicated app for authentication\n\nIf you want to use a dedicated app for GitHub authentication, you can create a GitHub OAuth app. You'll find general instructions for creating a GitHub OAuth App [here](https://docs.github.com/en/free-pro-team@latest/developers/apps/creating-an-oauth-app). Specify the following settings in your OAuth App:\n\n- Homepage URL – the public URL of your SonarQube server. For example, `https://sonarqube.mycompany.com`. For security reasons, HTTP is not supported, and you must use HTTPS. The public URL is configured in SonarQube at **Administration \u003e General \u003e Server base URL**.\n- Authorization callback URL – your instance's base URL. For example, https://yourinstance.sonarqube.com.\nAfter creating your app, update your global SonarQube settings:\n\nNavigate to **Administration \u003e Configuration \u003e General Settings \u003e ALM Integrations \u003e GitHub \u003e GitHub Authentication** and update the following:\n\n- **Enabled** – set the switch to true.\n- **Client ID** – the Client ID is found below the GitHub App ID on your GitHub App's page.\n- **Client Secret** – the Client secret is found below the Client ID on your GitHub App's page.\nNow, from the login page, your users can connect their GitHub accounts with the new \"Log in with GitHub\" button.\n\nWhen completed the configuration can be checked from the **Administration \u003e Configuration \u003e General Settings \u003e ALM Integrations** panel\n\n![](./imgs/SQ-github-config.png)\n\nAnd the \"Log in with GitHub\" button will now be available (in addition to standard user/pass authentication)\n\n![](./imgs/SQ-github-auth.png) \n\nReference: [https://docs.sonarqube.org/8.9/analysis/github-integration/](https://docs.sonarqube.org/8.9/analysis/github-integration/)\n\n## \u003ca name=\"jenkins\"\u003e\u003c/a\u003eJenkins integration\n\n### SonarScanner for Jenkins\n\nThis plugin lets you centralize the configuration of SonarQube server connection details in Jenkins global configuration.\n\nThen you can trigger SonarQube analysis from Jenkins using standard Jenkins Build Steps or [Jenkins Pipeline DSL](https://jenkins.io/solutions/pipeline/) to trigger analysis with:\n\n- SonarScanner\n- SonarScanner for Maven\n- SonarScanner for Gradle\n- SonarScanner for .NET\n\nOnce the job is complete, the plugin will detect that a SonarQube analysis was made during the build and display a badge and a widget on the job page with a link to the SonarQube dashboard as well as quality gate status.\n\n### Installation\n\n1. Install the [SonarQube Scanner for Jenkins](https://plugins.jenkins.io/sonar) via the Jenkins Update Center.\n2. Configure your SonarQube server(s):\n    - Log into Jenkins as an administrator and go to **Manage Jenkins \u003e Configure System**.\n    - Scroll down to the SonarQube configuration section, click **Add SonarQube**, and add the values you're prompted for.\n    - The server [authentication token](https://docs.sonarqube.org/8.9/user-guide/user-token/) should be created as a 'Secret Text' credential.\n\n![](./imgs/SQ-sonar-jenkins-token.png)\n![](./imgs/SQ-jenkins-token.png)\n![](./imgs/SQ-jenkins-add-sonar.png)\n\n### Analyzing other project types\n\n**Global Configuration**\n\nThis step is mandatory if you want to trigger any of your SonarQube analyses with the SonarScanner. You can define as many scanner instances as you wish. Then for each Jenkins job, you will be able to choose which launcher to use to run the SonarQube analysis.\n\n1. Log into Jenkins as an administrator and go to **Manage Jenkins \u003e Global Tool Configuration**\n2. Scroll down to the SonarScanner configuration section and click on Add SonarScanner. It is based on the typical Jenkins tool auto-installation. You can either choose to point to an already installed version of SonarScanner (uncheck 'Install automatically') or tell Jenkins to grab the installer from a remote location (check 'Install automatically')\n\nIf you don't see a drop-down list with all available SonarScanner versions but instead see an empty text field then this is because Jenkins still hasn't downloaded the required update center file (default period is 1 day). You may force this refresh by clicking the 'Check Now' button in **Manage Plugins \u003e Advanced** tab.\n\n![](./imgs/SQ-jenkins-add-scanner.png)\n\n**Job Configuration**\n\n1. **Configure** the project, and go to the **Build** section.\n2. Add the SonarScanner build step to your build.\n3. Configure the SonarQube analysis properties. You can either point to an existing `sonar-project.properties` file or set the analysis properties directly in the **Analysis properties** field\n    \n![](./imgs/SQ-jenkins-job-scanner.png)\n\nReference: [https://docs.sonarqube.org/8.9/analysis/scan/sonarscanner-for-jenkins/](https://docs.sonarqube.org/8.9/analysis/scan/sonarscanner-for-jenkins/)\n\n## \u003ca name=\"teardown\"\u003e\u003c/a\u003eTeardown\n\nAll containers must be stopped and removed along with the volumes and network that were created for the application containers\n\nCommands\n\n```console\ndocker-compose stop\ndocker-compose rm -fv\ndocker volume rm ce-postgresql ce-postgresql-data ce-sonarqube-data ce-sonarqube-extensions ce-sonarqube-logs \ndocker network rm ce-sonar\n```\n\nExpected output\n\n```console\n$ docker-compose stop\n[+] Running 3/3\n ⠿ Container ce-nginx      Stopped                                                                                                     0.2s\n ⠿ Container ce-sonarqube  Stopped                                                                                                     1.4s\n ⠿ Container ce-database   Stopped\n$ docker-compose rm -fv\nGoing to remove ce-nginx, ce-sonarqube, ce-database\n[+] Running 3/0\n ⠿ Container ce-database   Removed                                                                                                     0.0s\n ⠿ Container ce-sonarqube  Removed                                                                                                     0.1s\n ⠿ Container ce-nginx      Removed\n$ docker volume rm ce-postgresql ce-postgresql-data ce-sonarqube-data ce-sonarqube-extensions ce-sonarqube-logs\nce-postgresql\nce-postgresql-data\nce-sonarqube-data\nce-sonarqube-extensions\nce-sonarqube-logs\n$ docker network rm ce-sonar\nce-sonar\n```\n\n## \u003ca name=\"references\"\u003e\u003c/a\u003eReferences\n\n- SonarQube Documentation: [https://docs.sonarqube.org/latest/](https://docs.sonarqube.org/latest/)\n- Docker images: [https://hub.docker.com/_/sonarqube/](https://hub.docker.com/_/sonarqube/)\n\n---\n\n## \u003ca name=\"notes\"\u003e\u003c/a\u003eNotes\n\nGeneral information regarding standard Docker deployment of SonarQube for reference purposes\n\n### Let's Encrypt SSL Certificate\n\nUse: [https://github.com/RENCI-NRIG/ez-letsencrypt](https://github.com/RENCI-NRIG/ez-letsencrypt) - A shell script to obtain and renew [Let's Encrypt](https://letsencrypt.org/) certificates using Certbot's `--webroot` method of [certificate issuance](https://certbot.eff.org/docs/using.html#webroot).\n\n### Installing SonarQube from the Docker Image\n\nFollow these steps for your first installation:\n\n1. Creating the following volumes helps prevent the loss of information when updating to a new version or upgrading to a higher edition:\n    - `sonarqube_data` – contains data files, such as the embedded H2 database and Elasticsearch indexes\n    - `sonarqube_logs` – contains SonarQube logs about access, web process, CE process, and Elasticsearch\n    - `sonarqube_extensions` – will contain any plugins you install and the Oracle JDBC driver if necessary.\n\n    Create the volumes with the following commands:\n    \n    ```console\n    docker volume create --name sonarqube_data\n    docker volume create --name sonarqube_logs\n    docker volume create --name sonarqube_extensions\n    ```\n\n2. Drivers for supported databases (except Oracle) are already provided.\n    - Create the database volumes (e.g. PostgreSQL):\n\n    ```console\n    docker volume create --name postgresql_data\n    docker volume create --name postgresql\n    ```\n3. Run the image with your database properties defined using the `-e` environment variable flag:\n\n    ```console\n    docker run -d --name sonarqube \\\n        -p 9000:9000 \\\n        -e SONAR_JDBC_URL=... \\\n        -e SONAR_JDBC_USERNAME=... \\\n        -e SONAR_JDBC_PASSWORD=... \\\n        -v sonarqube_data:/opt/sonarqube/data \\\n        -v sonarqube_extensions:/opt/sonarqube/extensions \\\n        -v sonarqube_logs:/opt/sonarqube/logs \\\n        \u003cimage_name\u003e\n    ```\n\n### Example Compose definition\n\n```yaml\nversion: \"3\"\n\nservices:\n  sonarqube:\n    image: sonarqube:community\n    depends_on:\n      - db\n    environment:\n      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar\n      SONAR_JDBC_USERNAME: sonar\n      SONAR_JDBC_PASSWORD: sonar\n    volumes:\n      - sonarqube_data:/opt/sonarqube/data\n      - sonarqube_extensions:/opt/sonarqube/extensions\n      - sonarqube_logs:/opt/sonarqube/logs\n    ports:\n      - \"9000:9000\"\n  db:\n    image: postgres:12\n    environment:\n      POSTGRES_USER: sonar\n      POSTGRES_PASSWORD: sonar\n    volumes:\n      - postgresql:/var/lib/postgresql\n      - postgresql_data:/var/lib/postgresql/data\n\nvolumes:\n  sonarqube_data:\n  sonarqube_extensions:\n  sonarqube_logs:\n  postgresql:\n  postgresql_data:\n```\n\n### Generating and Using Tokens\n\nUsers can generate tokens that can be used to run analyses or invoke web services without access to the user's actual credentials.\n\n**Generating a token**\n\nYou can generate new tokens at **User \u003e My Account \u003e Security**.\n\nThe form at the bottom of the page allows you to generate new tokens. Once you click the Generate button, you will see the token value. Copy it immediately; once you dismiss the notification you will not be able to retrieve it.\n\n**Revoking a token**\n\nYou can revoke an existing token at **User \u003e My Account \u003e Security** by clicking the **Revoke** button next to the token.\n\n**Using a token**\n\nUser tokens must replace your normal login process in the following scenarios:\n\n- when running analyses on your code: replace your login with the token in the sonar.login property.\n- when invoking web services: just pass the token instead of your login while doing the basic authentication.\n\nIn both cases, you don't need to provide a password (so when running analyses on your code, the property `sonar.password` is optional). Using a token is the preferred method over using a login and password.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjstealey%2Fsonarqube-ce-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjstealey%2Fsonarqube-ce-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjstealey%2Fsonarqube-ce-docker/lists"}