Deploy SonarQube

Self-hosted SonarQube code analysis with Postgres and no default login

Deploy SonarQube

/var/lib/postgresql/data

/sonarqube

Deploy and Host SonarQube on Railway

SonarQube is an open-source code quality and security server from SonarSource. It analyzes source code in many languages, including Java, JavaScript, TypeScript, Python, C#, Go and PHP, and reports bugs, vulnerabilities, security hotspots, code smells, duplication and test coverage for each project you scan.

About Hosting SonarQube

SonarQube runs three Java processes: a web server, a compute engine that processes scan reports, and an embedded Elasticsearch index. It needs a PostgreSQL database, a persistent disk for its search indexes and plugins, and at least 2 GB of RAM. This template deploys SonarQube Community Build 26.11, built from a public GitHub repository that pins the official image by digest, plus Railway PostgreSQL. A small start script replaces the default admin/admin login with a generated password before the public URL opens. It keeps indexes and plugins on a volume, and works on hosts with a low vm.max_map_count. The first boot takes one to two minutes.

Common Use Cases

  • Run static analysis on every main-branch build from GitHub Actions, GitLab CI, Jenkins or Azure Pipelines
  • Fail a CI build when new code misses a quality gate: coverage, duplication, or new bugs and vulnerabilities
  • Track technical debt and security hotspots across many repositories from one self-hosted dashboard

Dependencies for SonarQube Hosting

  • PostgreSQL (Railway PostgreSQL service, included)
  • A Railway volume for Elasticsearch indexes and Marketplace plugins (included)

Deployment Dependencies

Implementation Details

Log in as admin with the password in the SonarQube service's SONAR_ADMIN_PASSWORD variable. It is generated at deploy time and applied on first boot only. After that, change the password in SonarQube under My Account, Security.

To scan a project, create a project and a token in SonarQube, then run a scanner against your Railway URL:

docker run --rm -v "$PWD:/usr/src" -e SONAR_HOST_URL=https://YOUR-DOMAIN -e SONAR_TOKEN=YOUR-TOKEN sonarsource/sonar-scanner-cli -Dsonar.projectKey=my-project

SONAR_CORE_SERVERBASEURL defaults to the Railway domain. Change it if you add a custom domain. Updates to the pinned SonarQube version arrive as Railway update notices. SonarQube migrates its database on start, so back up Postgres before applying a major upgrade.

Why Deploy SonarQube on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying SonarQube on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
52