Railway

Deploy Forgejo

Self-host Forgejo, a lightweight Git forge, with CI, Postgres and Redis

Deploy Forgejo

Just deployed

/data

/var/lib/postgresql/data

Just deployed

Just deployed

/data

forgejo-storage

Bucket

Just deployed

Forgejo logo

Deploy and Host Forgejo on Railway

Forgejo is a lightweight, community-governed Git forge: repositories, pull requests, issues, releases, a package registry and built-in CI, all from a single Go binary. It began in 2022 as a fork of Gitea led by the people behind Codeberg, is published under the GPL-3.0-or-later licence with no paid edition, and has become the default choice for teams who want GitHub's workflow without GitHub's ownership of their code. Small teams, universities and open-source projects self-host Forgejo for private repositories, auditable access control and CI they control.

This template lets you deploy Forgejo on Railway with the parts a real forge needs already wired together: the Forgejo web and SSH service, a Forgejo Actions runner so CI actually executes, PostgreSQL for metadata, Redis for cache, sessions and queues, a storage bucket for attachments, LFS objects, packages and CI logs, and a volume for the Git repositories. Browser traffic arrives over HTTPS on the public domain, git push over HTTPS or over SSH through a TCP proxy, and the runner reaches Forgejo over Railway's private network. The first administrator account is created before the web server accepts its first request, so the instance is never reachable without an owner.

Forgejo Railway architecture

Getting Started with Forgejo on Railway

Open the public URL once the deployment is green and you will land on a working forge with registration already closed. Sign in with the administrator username and password you set at deploy time — there is no setup wizard and no default password to change, because the account is created during the first boot. Create your first repository from the + menu, tick Initialize repository, and clone it over HTTPS using the URL on the repository page. For SSH, add a public key under Settings → SSH / GPG keys and clone from the address on the SSH tab, which already carries the proxy host and port. To confirm CI is alive, commit a workflow at .forgejo/workflows/ci.yml with runs-on: host and push: the run appears under the repository's Actions tab within seconds. The bundled runner shows as idle under Site Administration → Actions → Runners, and you can invite your team from Site Administration → User Accounts.

Forgejo repository page showing files and rendered README Forgejo Actions run with passing job steps and output Forgejo issue thread with a CSV file attached

About Hosting Forgejo

Forgejo does what a Git host has to do and stops there: it serves repositories, reviews code and runs CI, without the sprawl that makes larger platforms expensive to operate. Self-host it when code must stay on infrastructure you control, or when per-seat pricing stops making sense.

  • Repositories with pull requests, code review, protected branches and required checks
  • Issues, labels, milestones, projects and a per-repository wiki
  • Forgejo Actions, a CI system whose workflow syntax is compatible with GitHub Actions
  • A package registry covering container images, npm, Maven, PyPI, Cargo, NuGet and more
  • Git LFS, mirroring, releases, a REST API, organisations, teams and two-factor authentication

The forge runs as one service because Git repositories live on a filesystem, and the volume at /data makes them durable across restarts. PostgreSQL holds every row that is not a Git object: users, issues, pull requests, CI runs. Redis carries the cache, sessions and queues, so a redeploy does not sign everyone out.

Why Deploy Forgejo on Railway

Railway removes the operational work that usually comes with running a forge.

  • PostgreSQL, Redis and object storage are provisioned and connected for you
  • The public HTTPS domain and its certificate are issued automatically
  • A TCP proxy exposes Git over SSH without running your own server
  • The Actions runner is registered at deploy time, so CI works immediately
  • Volumes, health checks and restart policies are configured already

Common Use Cases

  • A private forge for a team that wants GitHub's workflow on its own infrastructure
  • Client or contract work whose source cannot sit on a third-party platform
  • Mirroring public repositories to keep a durable, self-owned copy with its own CI
  • Publishing internal container images, npm packages or Python wheels

Dependencies for Forgejo

  • Forgejocodeberg.org/forgejo/forgejo:16: web UI, Git HTTP, SSH and API
  • Forgejo Actions runnercode.forgejo.org/forgejo/runner:13, runs CI workflows
  • PostgreSQL 18 — repository metadata, issues, pull requests, CI history
  • Redis — cache, session store and background queues
  • Storage bucket — attachments, avatars, LFS, packages, release assets, job logs
  • Volume at /data — Git repositories and SSH host keys

Environment Variables Reference

VariablePurpose
FORGEJO_ADMIN_USERNAME / _PASSWORD / _EMAILThe first administrator account
FORGEJO_RUNNER_SECRETShared secret linking the runner to the forge
FORGEJO_RUNNER_LABELSLabels a workflow's runs-on must match
FORGEJO_RUNNER_CAPACITYConcurrent CI jobs per runner
FORGEJO__service__DISABLE_REGISTRATIONSet false to allow public signup
FORGEJO__mailer__ENABLEDSet true and add SMTP settings to send notifications

Any setting in Forgejo's app.ini can be supplied as FORGEJO__<section>__; a dot inside a section name is escaped as _0X2E_.

Deployment Dependencies

Hardware Requirements for Self-Hosting Forgejo

ResourceMinimumRecommended
CPU1 vCPU2 vCPU, plus 2 for the runner
RAM512 MB2 GB, plus 2 GB for the runner
Storage5 GB volume20 GB+, sized to your repositories
RuntimeGo binary, Linux containerPostgreSQL 18, Redis, S3-compatible storage

Forgejo is frugal — the binary idles in a few hundred megabytes. CI consumes the resources, so give the runner headroom matching the builds you expect.

Self-Hosting Forgejo with Docker

The template needs none of this, but it is what running Forgejo yourself looks like. Start the forge with SQLite and a local volume:

docker run -d --name forgejo \
  -p 3000:3000 -p 222:22 \
  -v forgejo-data:/data \
  codeberg.org/forgejo/forgejo:16

Point it at PostgreSQL with environment variables instead of editing app.ini by hand:

docker run -d --name forgejo \
  -e FORGEJO__database__DB_TYPE=postgres \
  -e FORGEJO__database__HOST=postgres:5432 \
  -e FORGEJO__database__NAME=forgejo \
  -e FORGEJO__database__USER=forgejo \
  -e FORGEJO__database__PASSWD=changeme \
  -v forgejo-data:/data codeberg.org/forgejo/forgejo:16

How Much Does Forgejo Cost to Self-Host?

Forgejo is free software under the GPL-3.0-or-later licence: no paid tier, no enterprise edition, no per-seat pricing, every feature including CI and the package registry available to everyone. Self-hosting costs only infrastructure, so on Railway you pay for the compute, storage and bandwidth the forge and its runner use. CI usually moves the bill.

Forgejo vs Gitea vs GitLab CE

ForgejoGiteaGitLab CE
GovernanceNon-profit, electedFor-profit companyPublic company
LicenceGPL-3.0-or-laterMIT, open-core add-onsMIT, paid tiers
FootprintGo binary, ~512 MBGo binary, ~512 MB4 GB+, several services
CIForgejo ActionsGitea ActionsGitLab CI

Forgejo and Gitea feel almost identical to use; the difference is who decides where the project goes. GitLab CE is heavier, worth it for a whole DevOps suite rather than a Git forge.

FAQ

What is Forgejo?

A self-hosted Git forge for hosting repositories, reviewing pull requests, tracking issues and running CI, maintained by a non-profit under the GPL-3.0-or-later licence.

What does this Railway template deploy?

Forgejo, a Forgejo Actions runner, PostgreSQL, Redis and a storage bucket, plus a volume for Git repositories, a public HTTPS domain and a TCP proxy for Git over SSH.

Why does the template include PostgreSQL, Redis and a storage bucket?

Forgejo can run on SQLite and local disk, but that does not survive a container being replaced. PostgreSQL holds the metadata, Redis keeps sessions and queues out of process memory, and the bucket stores attachments, LFS objects and packages without filling the volume.

How do I run CI on self-hosted Forgejo?

The runner ships registered and idle. Commit a workflow to .forgejo/workflows/ with runs-on: host and push. Syntax is largely GitHub Actions compatible, so many workflows run with only the runs-on line changed.

How do I add users if registration is disabled?

Create them from Site Administration → User Accounts, or set FORGEJO__service__DISABLE_REGISTRATION to false to reopen signup.

Is CI isolated from the forge?

The runner executes jobs in its own container, separate from Forgejo, but workflow steps are not sandboxed from that container. Give push access only to people you trust with it.


Template Content

More templates in this category

View Template
Rocky Linux
[Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
41
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

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

Letta
51