---
title: "Deploy GitLab CE"
description: "Self-hosted GitLab CE: Git, merge requests and CI/CD. GitHub alternative."
category: "Other"
url: https://railway.com/deploy/gitlab-ce-self-hosted
---

# Deploy GitLab CE

Self-hosted GitLab CE: Git, merge requests and CI/CD. GitHub alternative.

**[Deploy GitLab CE on Railway](https://railway.com/template/gitlab-ce-self-hosted)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/gitlab-ce-self-hosted/manifest.json

- **Creator:** blueorange
- **Category:** Other

## Template content

### GitLab https://about.gitlab.com/images/ico/favicon-192x192.png

- **Image:** gitlab/gitlab-ce:19.5.0-ce.0
- **Start command:** `/bin/bash -c 'set -e; mkdir -p /var/opt/gitlab/etc-gitlab; if [ ! -L /etc/gitlab ]; then cp -an /etc/gitlab/. /var/opt/gitlab/etc-gitlab/ 2>/dev/null || true; rm -rf /etc/gitlab; ln -s /var/opt/gitlab/etc-gitlab /etc/gitlab; fi; set +e; /assets/init-container & child=$!; trap "gitlab-ctl stop sidekiq; gitlab-ctl stop puma; gitlab-ctl stop; rc=\$?; kill -TERM $child 2>/dev/null; wait $child; exit \$rc" TERM; wait $child'`
- **Health check:** /users/sign_in
- **Public domain:** Yes

## Documentation

# Deploy and Host GitLab CE on Railway

![GitLab logo](https://gitlab.com/gitlab-com/gitlab-artwork/-/raw/master/logo/logo-extra-whitespace.png)

GitLab Community Edition is the free, MIT-licensed edition of GitLab, with **24,000+ GitHub stars** on its mirror: Git hosting, merge requests with code review, issues, wikis and built-in CI/CD in one app. This template runs the official GitLab image on Railway with HTTPS and Git over SSH. GitLab.com Premium is $29 per user per month — self-hosting CE removes per-seat pricing and keeps your code on infrastructure you control.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **GitLab** | Official `gitlab/gitlab-ce` image, pinned to 19.5.0. Web UI and HTTPS clone URLs on your Railway domain (port 80), Git over SSH through a TCP proxy on port 22. |
| **Persistent Volume** | Mounted at `/var/opt/gitlab` — repositories, the bundled PostgreSQL database, uploads and GitLab's configuration survive redeploys. |

One container runs GitLab's whole Omnibus stack (Rails, Sidekiq, Gitaly, PostgreSQL, Redis, NGINX). The template moves `/etc/gitlab` onto the volume, so settings and secrets persist too.

---

## About Hosting GitLab

GitLab is a big application: a self-managed install normally means a VM, a reverse proxy, TLS certificates, SSH port mapping, backups and a long first boot. Getting clone URLs, SSH ports and HTTPS to agree is where most setups go wrong.

On Railway, the template wires `external_url` to your Railway domain, sets SSH clone URLs to the TCP proxy's host and port, generates the root password, and gives the first boot up to 30 minutes to finish before health checks count. Shutdowns get two minutes so GitLab stops cleanly.

**GitLab needs a lot of memory.** GitLab's own requirements start at 8 GB of RAM even for memory-constrained installs, and recommend 16 GB. The template runs Puma in single-process mode to save memory, but expect the service to use several gigabytes and budget accordingly; Railway Pro gives more headroom than Hobby. For a small team that only needs Git and pull requests, a lighter server like Gitea may be cheaper.

Typical cost: **~$40–80/month** on Railway, depending on memory use and team size, with unlimited users. GitLab.com Premium is $29 per user per month, so a 5-person team pays $145/month.

---

## Deploy GitLab in Under 30 Minutes

1. Click **Deploy on Railway** — GitLab's first boot configures everything (15–30 minutes).
2. In the **GitLab** service's Variables, reveal `GITLAB_ROOT_PASSWORD`.
3. Open your Railway URL and sign in as `root` with that password; change it in your profile.
4. Turn off open sign-up in Admin Area → Settings → General, then invite your team.
5. Add your SSH key and push your first repository over HTTPS or SSH.

No VM. No Certbot. No SSH port juggling.

---

## Common Use Cases

- **Self-hosted GitHub alternative** — "self hosted gitlab" with private repos and no per-seat fee
- **Private code hosting** — keep source code on infrastructure you control
- **Merge requests and code review** — GitLab's full review workflow for your team
- **Issue tracking and boards** — plan work next to the code
- **CI/CD pipelines** — define pipelines in `.gitlab-ci.yml` and add your own runners
- **Mirror and back up GitHub repos** — pull mirroring into your own instance

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `GITLAB_ROOT_PASSWORD` | 🔐 Auto-generated | Password for `root`, applied on first start only. Change it in the UI afterwards. |
| `GITLAB_HOST` | ✅ Auto-injected | Domain used in links and HTTPS clone URLs. Update it with a custom domain. |
| `GITLAB_OMNIBUS_CONFIG` | Optional | Extra `gitlab.rb` settings, separated by semicolons — add SMTP or object storage here. |
| `GITLAB_PUMA_WORKERS` | Optional | `0` runs one web process to save memory; raise it for more traffic. |
| `GITLAB_SIDEKIQ_CONCURRENCY` | Optional | Background job threads, `10` by default. |
| `GITLAB_SSH_HOST`, `GITLAB_SSH_PORT` | ✅ Auto-injected | TCP proxy host and port used in SSH clone URLs. Don't change. |

**Give the first boot time.** GitLab can take 15–30 minutes to start the first time; the template's health check waits up to 30 minutes, so let the deploy finish instead of restarting it.

---

## GitLab CE vs. Alternatives

| | GitLab CE on Railway | GitLab.com | GitHub | Gitea (self-hosted) |
|---|---|---|---|---|
| **Monthly cost** | ~$40–80 usage, any team size | Free (5 users), $29 per user Premium | Free, $4 per user Team | Free, you host it |
| **Self-hosted** | ✅ Yes | ❌ No | ❌ No (cloud plans) | ✅ Yes |
| **Per-user pricing** | ✅ None | ❌ Per user | ❌ Per user | ✅ None |
| **Built-in CI/CD** | ✅ GitLab CI | ✅ 400 free minutes | ✅ 2,000 free minutes | ⚠️ Gitea Actions |
| **Resource needs** | ❌ 8 GB+ RAM | ✅ Managed | ✅ Managed | ✅ Very light |
| **Code stays on your infra** | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
| **License** | ✅ MIT (CE) | ⚠️ Open core | ❌ Proprietary | ✅ MIT |

---

## Dependencies for GitLab Hosting

- Railway account — plan for several GB of RAM (GitLab recommends 8–16 GB); Railway Pro is the comfortable choice.
- An SMTP provider if you want email notifications (configured through `GITLAB_OMNIBUS_CONFIG`; Railway blocks SMTP on Hobby).
- GitLab Runners (separate service or machine) if you want CI/CD jobs to run.

### Deployment Dependencies

- [GitLab Docker Docs](https://docs.gitlab.com/install/docker/) — running the official image
- [GitLab Requirements](https://docs.gitlab.com/install/requirements/) — CPU and memory sizing
- [GitLab Runner](https://docs.gitlab.com/runner/) — executing CI/CD jobs
- [Railway Volumes Documentation](https://docs.railway.com/volumes) — persistence

### Implementation Details

The start command copies `/etc/gitlab` onto the volume on first boot and symlinks it back, so configuration and generated secrets persist, then runs GitLab's init and traps shutdown signals to stop Sidekiq and Puma cleanly. `GITLAB_OMNIBUS_CONFIG` sets `external_url` from `GITLAB_HOST` and points NGINX at the right port behind Railway's proxy.

Git over SSH goes through Railway's TCP proxy: clone URLs use `GITLAB_SSH_HOST` and `GITLAB_SSH_PORT`. Back up the volume regularly with Railway volume backups or `gitlab-backup`, and upgrade by changing the pinned image tag one supported step at a time.

---

## Frequently Asked Questions

**What is GitLab CE and why self-host it?**
GitLab Community Edition is the free, open-source edition of GitLab with Git hosting, code review, issues and CI/CD. Self-hosting keeps code on your own infrastructure and removes per-user pricing.

**How much does self-hosting GitLab cost compared to GitLab.com or GitHub?**
Expect roughly $40–80/month on Railway, mostly memory, with unlimited users. GitLab.com Premium is $29 per user per month and GitHub Team is $4 per user; for small teams that only need Git, GitHub or Gitea can be cheaper.

**Why is GitLab slow to start or showing 502 errors?**
The first boot takes 15–30 minutes, and GitLab needs several GB of RAM. Wait for the deploy to finish, and give the service more memory if Puma or Sidekiq keep restarting.

**Do I lose repositories when I redeploy?**
No. Repositories, the database, uploads and configuration are all on the `/var/opt/gitlab` volume. Back it up regularly anyway.

**Can I clone over SSH?**
Yes. SSH goes through Railway's TCP proxy, and clone URLs already include the proxy's host and port. Add your public key in your GitLab profile.

**Do CI/CD pipelines work out of the box?**
GitLab CI is built in, but jobs need a GitLab Runner. Register a runner on another Railway service or your own machine.

---

## Why Deploy and Host GitLab CE 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 CE on Railway, you get private Git hosting, code review and CI/CD for your whole team with no per-seat fees, on infrastructure you control.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/gitlab-ce-self-hosted
