Overview
This template provides a production‑ready SonarQube instance as a Monk runnable. You can:- Run it directly to get a managed code quality and security platform
- Inherit it in your own runnable to seamlessly add continuous code inspection to your CI/CD pipeline
What this template manages
- SonarQube server container (
sonarqubeimage, configurable tag) - PostgreSQL database for persistent storage
- Network service on port 9000 (Web UI and API)
- Analysis engine and quality gates
- Persistent volumes for data, extensions, and logs
Quick start (run directly)
- Load templates
- Run SonarQube with database
- Customize credentials (recommended via inheritance)
variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
- Preferred: inherit and replace variables with
secret("...")as shown below. - Alternative: fork/clone and edit the
variablesin the YAML files, thenmonk load MANIFESTand run.
http://localhost:9000. Default credentials: admin / admin (change immediately!)
Configuration
Key variables you can customize in this template:${monk-volume-path}/sonarqube and ${monk-volume-path}/postgres on the host.
Use by inheritance (recommended for CI/CD)
Inherit the SonarQube runnable in your CI/CD pipeline and declare a connection. Example:Ports and connectivity
- Service:
sonarqubeon TCP port9000 - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the SonarQube host.
Persistence and configuration
- SonarQube data:
${monk-volume-path}/sonarqube/data:/opt/sonarqube/data - Extensions:
${monk-volume-path}/sonarqube/extensions:/opt/sonarqube/extensions - Logs:
${monk-volume-path}/sonarqube/logs:/opt/sonarqube/logs - PostgreSQL data:
${monk-volume-path}/postgres:/var/lib/postgresql/data
Features
- Code Quality Analysis: Detect bugs, code smells, and technical debt
- Security Scanning: Find vulnerabilities and security hotspots
- 25+ Languages: Java, JavaScript, TypeScript, Python, C#, Go, PHP, etc.
- Quality Gates: Define pass/fail criteria for builds
- Pull Request Decoration: Automatic PR comments in GitHub, GitLab, etc.
- Custom Rules: Create organization-specific quality standards
- Historical Trends: Track code quality over time
- Integration: Jenkins, GitLab CI, GitHub Actions, Azure DevOps
CI/CD Integration
Example with Maven:Supported Languages
- Java, JavaScript, TypeScript
- Python, PHP, C#, VB.NET
- C, C++, Objective-C
- Go, Kotlin, Ruby, Scala
- HTML, CSS, XML
- And many more…
Use cases
SonarQube excels at:- Continuous code quality monitoring
- Security vulnerability detection
- Technical debt management
- Code review automation
- Compliance and standards enforcement
- Developer education on best practices
Related templates
- Integrate with source control (GitLab, GitHub) for automated code analysis
- Use with artifact repositories (
nexus/,artifactory/) for build integration - Combine with CI/CD platforms (Jenkins, GitLab CI) for continuous inspection
Troubleshooting
- Access SonarQube UI at
http://localhost:9000(default credentials:admin/admin) - Generate API token: Administration → Security → Users → Tokens
- Check system health: Administration → System
- Verify database connection in logs
- Check logs:
- If analysis is slow, increase JVM heap size in
sonar-web-javaOptsandsonar-ce-javaOpts - Ensure PostgreSQL is running and accessible before starting SonarQube
- For large projects, allocate more resources (4GB+ RAM recommended)
- Check Elasticsearch storage requirements for large codebases