Deploy Gogs
Lightweight self-hosted Git service, with Postgres, volume and SSH
Just deployed
/var/lib/postgresql/data
Just deployed
/data
Deploy and Host Gogs on Railway
Gogs is a painless, self-hosted Git service written in Go. It gives you repositories, issues, pull requests, wikis, organisations, webhooks and a REST API in one small binary that needs little CPU or memory. It's MIT-licensed and a lightweight alternative to GitHub or GitLab for private code hosting.
About Hosting Gogs
This template runs the official gogs/gogs image, version 0.14.4 pinned by digest, built from a public GitHub repo, with Railway's Postgres. Git repositories, config, SSH host keys, avatars and attachments live on a volume at /data, so they survive redeploys. A start script writes Gogs' app.ini from service variables on every start: the public URL comes from the Railway domain, and the web install wizard never opens, so nobody can claim your instance. An admin account owner is created on the first start with a generated password. Self-registration is off. A TCP proxy to port 22 enables git over SSH.
Common Use Cases
- Host private Git repositories for yourself or a small team
- Track issues, review pull requests and keep project wikis next to the code
- Mirror GitHub or GitLab repositories and trigger CI or chat tools with webhooks
Dependencies for Gogs Hosting
- PostgreSQL (included: Railway's Postgres service)
- A volume for repositories and Gogs data (included, mounted at
/data)
Deployment Dependencies
- Gogs source and releases: https://github.com/gogs/gogs (v0.14.4)
- Official image: https://hub.docker.com/r/gogs/gogs
- Configuration reference (
app.ini): https://github.com/gogs/gogs/blob/v0.14.4/conf/app.ini - Template repo: https://github.com/aalfath/gogs-railway-template
Implementation Details
There are no prompts at deploy time. After the deploy, open the public URL and sign in as owner with the password in the Gogs service's GOGS_ADMIN_PASSWORD variable (it's generated per deploy). Change it under Your Settings → Password if you like. Add more users under Admin Panel → Users, or set GOGS_DISABLE_REGISTRATION=false to allow sign-ups.
HTTPS clone and push work at once. For SSH, add your key under Your Settings → SSH Keys. Clone URLs use the TCP proxy, for example ssh://git@HOST.proxy.rlwy.net:PORT/owner/repo.git.
Custom domain: set GOGS_EXTERNAL_URL=https://git.YOUR-DOMAIN. Any other app.ini setting can be added as a variable named GOGS__section__KEY, for example GOGS__email__ENABLED=true for SMTP. Don't change GOGS_SECRET_KEY after the first deploy.
Updates: the service builds from the template repo, which pins each Gogs release by digest. When a new version is merged there, Railway shows an update notice in your project, and you choose when to apply it. Read the repo's CHANGELOG.md and back up the database and volume first, because migrations only run forward.
Why Deploy Gogs 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 Gogs 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
