Video coming soon…

🔍 Setup SonarQube — Code Quality Scanner

Deploy SonarQube Community Edition on Ubuntu to scan code for bugs, vulnerabilities, and technical debt across 30+ languages with CI/CD integration.

⚠️ This script is provided for demo and testing purposes only. Not intended for production use.
⚠️ System Requirements: SonarQube Community Edition requires at least 2 GB RAM and the vm.max_map_count kernel parameter set to 262144. The install script configures this automatically.

📦 Resources & Setup Scripts

Grab the automated bash script from GitHub to follow along with the video.

Automated install script — one command sets everything up.
View on GitHub

Quick Install:

wget https://raw.githubusercontent.com/mhmdali94/Docker/main/dev/sonarqube/sonarqube-ubuntu.sh
chmod +x sonarqube-ubuntu.sh
sudo bash sonarqube-ubuntu.sh

Tutorial Steps

1 Download the Script

wget https://raw.githubusercontent.com/mhmdali94/Docker/main/dev/sonarqube/sonarqube-ubuntu.sh

2 Make it Executable

chmod +x sonarqube-ubuntu.sh

3 Run the Installer

The script installs Docker if needed, then sets up the service automatically.

sudo bash sonarqube-ubuntu.sh

4 Access the Web UI

Open your browser and navigate to:

http://<your-server-ip>:9000

5 Run Your First Code Scan

Log in with the default credentials, change your password, generate a project token, then run sonar-scanner against your codebase.

# Default credentials: admin / admin
# Change immediately after first login
# Generate a project token at: My Account → Security → Generate Token
sonar-scanner \
  -Dsonar.projectKey=my-project \
  -Dsonar.sources=. \
  -Dsonar.host.url=http://<your-server-ip>:9000 \
  -Dsonar.token=YOUR_TOKEN

Ports Used

PortPurpose
9000SonarQube Web UI & API
5432PostgreSQL (internal)

Overview

SonarQube is the leading open-source platform for continuous code quality and security inspection. It statically analyses your source code to detect bugs before they reach production, highlight code smells that slow your team down, and surface security vulnerabilities (OWASP Top 10, CWE) before they become incidents. The Community Edition supports 30+ programming languages and integrates natively with CI/CD pipelines via Jenkins, GitHub Actions, GitLab CI, and Woodpecker. Teams that adopt SonarQube early reduce post-release defect rates by shifting quality left — catching issues in the development loop, not in QA.

Why Use It

SonarQube gives you a permanent, searchable record of your codebase's health across every commit. Unlike a linter that shows per-file warnings, SonarQube trends quality over time, sets quality gates (pass/fail criteria), and blocks broken code from being merged. For security-conscious teams, its SAST engine detects injection flaws, broken authentication, and sensitive data exposure patterns across all supported languages — without running the code.

When You Need It

    Who Should Use It

      Real Use Cases

        Main Features

          How to Use After Installation

            Security Best Practices

              Ports and Firewall Notes

              SonarQube uses port 9000 for its web interface and API. This port should never be exposed directly to the internet — proxy it through Nginx Proxy Manager with a valid TLS certificate. The embedded Elasticsearch engine requires the kernel parameter vm.max_map_count=262144 — the install script sets this automatically via /etc/sysctl.conf. PostgreSQL runs on the default port 5432 internally and should only be accessible within the Docker network.

              Backup and Maintenance

                Common Mistakes

                  Troubleshooting

                    Alternatives

                    Semgrep (free, faster, no server needed — excellent for SAST in CI without a dashboard), CodeClimate (cloud SaaS, simpler setup), Snyk (security-focused, integrates with GitHub), Checkmarx (enterprise SAST). SonarQube is the best self-hosted option when you need persistent trend data, quality gates, and multi-language support in one dashboard.

                    When Not to Use It

                    Skip SonarQube if your server has less than 2 GB RAM — it will crash and frustrate your team. Also avoid it for tiny single-developer projects where a linter (ESLint, Pylint, Rubocop) is sufficient. If you only need dependency vulnerability scanning (not code quality), Trivy or Snyk are lighter alternatives that need no server.

                    PrismaTechWork Professional Help

                    PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.

                      Contact Us

                      Frequently Asked Questions

                      Is SonarQube Community Edition free forever?

                      Yes. SonarQube Community Edition is completely free and open-source under the LGPL licence. The Developer, Enterprise, and Data Center editions add branch analysis, pull request decoration, and scaling features for larger teams, but Community Edition covers all core quality and security scanning for most use cases.

                      What is a 'code smell' in SonarQube?

                      A code smell is a maintainability issue — code that works today but is confusing, overly complex, or fragile. Examples include functions with too many parameters, deeply nested conditions, duplicated code blocks, and unused variables. SonarQube estimates the time (in minutes) required to fix each code smell, letting you track and pay down technical debt systematically.

                      Which programming languages does the free edition support?

                      Community Edition supports Java, JavaScript, TypeScript, Python, PHP, C#, C/C++, Go, Ruby, Kotlin, Scala, Swift, HTML, CSS, XML, and more — over 30 languages in total. Branch analysis (scanning feature branches separately) requires the paid Developer Edition.

                      How do I integrate SonarQube with Gitea or GitHub Actions?

                      Generate a project token in SonarQube, add it as a CI secret, then add a step that runs sonar-scanner with -Dsonar.host.url and -Dsonar.token parameters. For GitHub Actions, use the official SonarSource/sonarqube-scan-action. For Woodpecker CI, add a sonar-scanner step in your .woodpecker.yml pipeline definition.

                      What is SonarLint and do I need it?

                      SonarLint is a free IDE plugin (VS Code, IntelliJ, Eclipse) that shows SonarQube findings in real time as you type — before you even commit. It can connect to your SonarQube server (Connected Mode) to apply the same rules your team uses. It dramatically reduces the number of issues that reach CI by catching them at the keyboard.

                      How do I suppress false positive findings?

                      In the SonarQube UI, open the issue, click 'Won't Fix' or 'False Positive', and add a justification comment. This persists across future scans so the issue is not re-reported. For code-level suppression, use the @SuppressWarnings annotation in Java or a // NOSONAR comment in any language — but use these sparingly to avoid hiding real issues.

                      What is a Quality Gate and how do I configure one?

                      A Quality Gate is a set of pass/fail conditions applied to each analysis — for example 'no new critical issues', 'new code coverage ≥ 80%', or 'new duplications < 3%'. Create one at Administration → Quality Gates, set your conditions, then assign it to your project. Failed Quality Gates can block CI pipelines from proceeding, enforcing team standards automatically.

                      Can SonarQube scan Docker images or infrastructure-as-code files?

                      SonarQube Community Edition does not natively scan Dockerfiles or Terraform/Ansible files for infrastructure security — use Trivy (containers) or Checkov (IaC) for those. However, SonarQube will scan the application code inside your repo, including any embedded shell scripts. The Developer Edition adds CloudFormation and Kubernetes manifest scanning.