Deploy GitLab

Self-hosted Git server with CI/CD, issues and merge requests (GitLab CE)

Deploy GitLab

/var/opt/gitlab

Deploy and Host GitLab on Railway

Deploy on Railway

GitLab is an open-source DevOps platform and the best-known self-hosted alternative to GitHub: Git repositories with merge requests and code review, issues and boards, a wiki, a package registry, and CI/CD pipelines defined in .gitlab-ci.yml. This template runs GitLab Community Edition 19.6 from GitLab's official Omnibus image as one Railway service with one volume: the web app, Git storage, background jobs, PostgreSQL and Redis all run inside it, the way GitLab ships them.

This is a community template, not made or supported by GitLab Inc.

About Hosting GitLab

Deploy and open the Railway domain. A page says "GitLab is starting" for about four minutes on the first boot and then turns into the sign-in page. Sign in as root with the generated GITLAB_ROOT_PASSWORD from the GitLab service's Variables tab, then change the password under your profile: the variable is only read on the first boot.

Memory: GitLab is a large application. It uses about 3.5 GB at rest with this template's settings, so the service needs a memory limit of at least 4 GB (Hobby or Pro). On Railway's Free and Trial plans it cannot run; instead of crashing, the service shows a page that says so. Budget for the memory before you deploy: this is not a small-plan app.

Accounts: registration is closed, so nobody can sign up on your public address. Create users under Admin > Users, or open registration under Admin > Settings > General > Sign-up restrictions. GITLAB_SIGNUP_ENABLED=true before the first deploy leaves it open, with new accounts waiting for your approval.

Cloning: HTTPS works on the Railway domain with a personal access token as the password. SSH works too, through the Railway TCP proxy that comes with the template: every project's Clone button shows the right ssh://git@...proxy.rlwy.net:PORT/... address, and you add your public key under your profile as usual.

CI/CD runners: GitLab schedules pipelines, but jobs run on runners, and a runner with the Docker executor needs a Docker daemon that Railway services don't have. Install GitLab Runner on a machine of your own (a small VPS or your laptop) and register it under Admin > CI/CD > Runners. Everything else in CI/CD (pipelines, artifacts, variables, schedules) is served from here.

Email: off by default, because GitLab would otherwise queue mail it can't send. To turn it on, set SMTP_ADDRESS, SMTP_PORT, SMTP_USER_NAME, SMTP_PASSWORD and SMTP_FROM and redeploy. Railway allows outbound SMTP on the Pro plan only. Without email, reset a user's password under Admin > Users.

Your data: repositories, the database, uploads, CI artifacts and GitLab's secrets file are all on the service's volume at /var/opt/gitlab, and redeploys keep them. A fresh install uses about 0.6 GB; watch the volume as repositories and artifacts grow, and resize it in the volume's settings. For a copy outside Railway, run gitlab-backup create over railway ssh and download the archive from /var/opt/gitlab/backups, together with /etc/gitlab/gitlab-secrets.json: a backup can't be restored without that file.

Custom domain: add it under the service's Settings > Networking (port 80), set GITLAB_EXTERNAL_URL=https://git.example.com and redeploy. GitLab then uses it in links and clone addresses.

More settings: anything gitlab.rb accepts can be put in a GITLAB_OMNIBUS_CONFIG variable, one setting per line, for example gitlab_rails['time_zone'] = 'Europe/Warsaw'. PUMA_WORKERS=2 gives a larger team more web capacity for about 1 GB per worker.

Upgrades: the template pins a GitLab release, and your deployment stays on it until you change the image under the service's Settings > Source. Images are tagged by GitLab version (ghcr.io/two-workspaces/gitlab:19.6.2). GitLab only upgrades along its upgrade path: move one minor version at a time and never skip a required stop. Take a backup first.

Common Use Cases

  • A private Git server for a team, with merge requests, code review and protected branches
  • Moving off a GitHub or GitLab.com subscription to an instance you control
  • Issue tracking, boards, milestones and a wiki next to the code
  • A CI/CD coordinator for runners on your own machines
  • A private package and artifact store for npm, Maven, PyPI and generic packages

Dependencies for GitLab Hosting

  • A Railway plan that allows 4 GB of memory for one service (Hobby or Pro)
  • Nothing else to deploy: PostgreSQL, Redis and Git storage are inside the GitLab service
  • For CI/CD jobs: a GitLab Runner on a machine of your own
  • For email: an SMTP provider, and Railway's Pro plan

Deployment Dependencies

Implementation Details

  • Image: GitLab's official gitlab/gitlab-ce:19.6.2-ce.0, pinned, with a small entrypoint and one settings file added. It is built by GitHub Actions and pulled ready-made, so nothing is built on Railway.
  • One volume for data and secrets: GitLab keeps repositories and the database in /var/opt/gitlab and its secrets and SSH host keys in /etc/gitlab. A Railway service has one volume, so the volume holds the first and /etc/gitlab is a link into it. Losing gitlab-secrets.json on a redeploy would make every stored token and CI variable unreadable; here it stays.
  • Never a failed deploy for being slow: a small nginx owns the public port from the first second. It answers Railway's healthcheck, shows a status page while GitLab starts or restarts, and proxies to GitLab once it answers. TLS ends at Railway's edge, and GitLab is told it is served over https.
  • Never a crash loop: under 4 GB of memory, with a GITLAB_EXTERNAL_URL that isn't an address, or with a root password under 8 characters, GitLab is not started and the page says what to fix. If configuring GitLab fails for another reason, the page points to the deploy logs and GitLab tries again every ten minutes.
  • Closed before it is reachable: on the first boot the sign-up setting is switched off in the database, and visitors stay on the status page until that has taken effect. The root password is generated per deploy.
  • Memory settings: GitLab's own recommendations for a small server: one Puma process instead of a cluster, 10 Sidekiq threads, the bundled Prometheus stack and the Kubernetes agent server off, and memory handed back to the system sooner. Logs stay off the volume.
  • Not included: the container registry and GitLab Pages, which need more ports or domains than one Railway service exposes.

Why Deploy GitLab 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 GitLab 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
Double Commander in your browser
The Double Commander file manager in the cloud, from any device

Nermin Sabanovic
0