Deploy GitLab CE + CI Runner: Git hosting and CI/CD, GitHub alternative
Private Git repos, merge requests, issues and CI/CD with a built-in runner
Just deployed
/var/opt/gitlab
Runner
Just deployed
Deploy and Host GitLab on Railway
GitLab Community Edition is the free, MIT-licensed edition of GitLab: Git repositories, merge requests with code review, issues and boards, wikis and CI/CD pipelines in one application. This template runs the official GitLab image, pinned to an exact release, with HTTPS on your Railway domain and Git over SSH through a TCP proxy. A CI runner ships with it, switched off: paste one Railway token and every pipeline job runs in its own Railway sandbox. You get a private GitHub alternative on your own infrastructure without setting up a server, a reverse proxy, certificates or a runner machine.
About Hosting GitLab
GitLab ships as one container that runs everything it needs: PostgreSQL, Redis, Gitaly for repository storage, Sidekiq for background jobs, Puma for the web app and nginx in front. This template configures it for a single Railway service using GitLab's own low-memory settings, and keeps repositories, the database, uploads, GitLab's configuration and secrets, and the SSH host keys on one volume. CI/CD variables, two-factor secrets and SSH fingerprints survive every redeploy. The root password is generated for you. First boot takes about six minutes while GitLab sets up its database; redeploys take about three.
Common Use Cases
- Private Git hosting for a team: repositories, branches and history on infrastructure you control, cloned over HTTPS or SSH.
- Code review with merge requests: open a merge request from a branch, review the diff, approve and merge in the browser.
- Issue tracking and planning: issues, issue boards and a wiki next to the code they describe.
- CI/CD without a runner machine: pipelines defined in
.gitlab-ci.ymlrun on the bundled runner, each job in a fresh Railway sandbox with the Docker image the job names.
How to Use GitLab After Deployment
- Wait for the GitLab service to show Active. The first boot takes about six minutes.
- Open the service's public URL (GitLab service, Settings, Networking).
- Sign in as
root. The password isGITLAB_ROOT_PASSWORDin the GitLab service's Variables tab. - GitLab opens with two setup screens, Create your first project and Set up your profile. Fill them in or press Skip on each.
- Add your SSH key: avatar menu, Edit profile, SSH Keys. SSH clone URLs use the TCP proxy host and port, for example
ssh://git@example.proxy.rlwy.net:12345/group/project.git, and the project page shows the exact one. - Decide who may register. New accounts need an administrator's approval by default; to turn sign-up off, go to Admin, Settings, General, Sign-up restrictions.
- To run pipelines, switch the runner on: in your project's Settings, Tokens, create a token for this environment, paste it as
RAILWAY_TOKENon the Runner service and deploy. GitLab already lists the runner under Admin, CI/CD, Runners, and it goes online a few minutes later.
Dependencies for GitLab Hosting
- GitLab (
gitlab/gitlab-ce, pinned to an exact release): the whole application, with a volume at/var/opt/gitlab. - Runner (
alpine): GitLab Runner with a driver that starts one Railway sandbox per job. Off untilRAILWAY_TOKENis set.
Deployment Dependencies
Implementation Details
Memory: GitLab idles at about 3.2 to 3.5 GB on this template. The Hobby or Pro plan is required; Free and Trial services cannot hold it.
Configuration: every GitLab setting lives in GITLAB_OMNIBUS_CONFIG as gitlab.rb lines separated by semicolons. To change one, add a line at the end and redeploy.
CI runner: each job gets its own sandbox, which is created when the job starts and destroyed when it ends, so you pay for sandbox time only while jobs run (sandbox pricing). The job's image: is honoured, artifacts work, and allow_failure exit codes are passed through. Not supported yet: services:, a cache kept between jobs, and Docker commands inside a job. Images need a shell (sh or bash). Run more jobs at once with RUNNER_CONCURRENT. The Runner service itself uses about 2 MB of memory while off and about 50 MB while on.
Switched off to save memory: Prometheus monitoring and the Kubernetes agent server. The container registry and GitLab Pages are off too, since each needs its own hostname.
Email: GitLab sends no email until you add SMTP settings. Append them to GITLAB_OMNIBUS_CONFIG (gitlab_rails['smtp_enable'] = true; gitlab_rails['smtp_address'] = 'smtp.example.com'; ..., per GitLab's SMTP docs). Railway allows outbound SMTP on the Pro plan only.
How to Upgrade: change the image tag on the GitLab service to a newer gitlab/gitlab-ce release and redeploy. Follow GitLab's upgrade path and stop at each required version on the way. You can also turn on automatic image updates (GitLab service, Settings, Source, Configure Auto Updates) with Patches only, which keeps you on the same minor version. The pre-update volume backup is Pro plan only, so back up first on Hobby.
Is GitLab Free?
GitLab Community Edition is MIT-licensed with no user limit. The paid Premium and Ultimate tiers add features on top; repositories, merge requests, issues, wikis and CI/CD are all in the free edition. On Railway you pay only for the resources the service uses.
Why Choose This Template
- CI that runs on Railway, with nothing else to set up. A GitLab Runner ships with the template, switched off. Paste one Railway project token on the Runner service and pipelines start. GitLab registers the runner by itself, so there is no runner machine to rent and no registration token to copy.
- Every job in its own clean machine. Each job runs in a fresh Railway sandbox with the Docker image the job asks for, and the sandbox is destroyed when the job ends, so one job's leftovers never reach the next.
- You pay for CI only while jobs run. Sandboxes bill per second while a job runs; between jobs the runner itself uses about 50 MB of memory.
- Your data survives redeploys. Repositories, the database, GitLab's configuration and secrets, and the SSH host keys live on one volume, so CI/CD variables, two-factor secrets and SSH fingerprints stay put.
- Git over SSH works out of the box, through a TCP proxy, with clone URLs that show the right host and port.
- Pinned to an exact GitLab release. Templates that track the
latesttag pull whatever GitLab released most recently on every deploy, so a redeploy can break a working instance (GitLab refuses to start when an update skips one of its required upgrade versions), a new environment can run a different release from your current one, and two environments that look identical can drift apart.
We keep this template current: when GitLab ships a new release, we test it on a fresh deployment and then move this template's pinned version forward, so every new deployment gets the newest release we have seen work. Your existing deployment stays on its version until you choose to update it.
With a pinned release, updating is a choice you make and can test first:
- Duplicate your environment: open the environment dropdown in the top bar, choose + New Environment, then Duplicate Environment, and approve the staged changes.
- In the copy, open the GitLab service, go to Settings, Source, change the image tag to the release you want, and deploy the change.
- Test the copy. If it works, back up your main environment and make the same tag change there. Follow GitLab's upgrade path when moving across several releases.
FAQ
Why does my pipeline stay pending?
The runner is off until you set RAILWAY_TOKEN on the Runner service (step 7 above). You can also register a runner on a machine you run: Admin, CI/CD, Runners, Create instance runner (GitLab Runner docs).
Can a job reach my other Railway services?
Yes. Job sandboxes join the environment's private network, so service.railway.internal addresses work. The token you paste works only inside this project's environment.
Does Git over SSH work? Yes. Railway's TCP proxy forwards to GitLab's SSH server, and clone URLs already carry the proxy host and port.
Can I use my own domain?
Add the custom domain under Settings, Networking, then set GITLAB_HOST to it and redeploy so GitLab's links and HTTPS clone URLs use it.
How do I back up GitLab?
Run gitlab-backup create in the GitLab service's shell, then keep /etc/gitlab/gitlab-secrets.json with the backup (GitLab's backup docs). GitLab's restore docs cover the way back.
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
Runner
alpine:3.22.2