DevOpsDeploymentRailway

Shipping on Railway with Postgres and Git

April 18, 2024 • 14 min read

What Railway gets right

  • Fast deploys – Git push to a live URL in under a minute most days
  • Postgres in one command – No separate database account to set up
  • Sensible defaults – It detects the framework and builds it without a config file
  • TLS and a domain – Handled for you, which is one less thing to forget

Things I've shipped on it

  • Recruiter Copilot AI – Django + React + PostgreSQL
  • EssentialsDash – A product discovery side project
  • LifeGPT – A reflection app wired up to the OpenAI API
  • 20+ projects – All on the same workflow

I avoided Railway for ages because I assumed it'd be another toy PaaS. It isn't. I'd been writing Dockerfiles and fighting AWS for side projects that didn't need either, and the friction was enough that I stopped shipping them. Railway reads your repo, guesses the framework, and builds it. Usually it guesses right. I've put 20-odd projects through it now, and the workflow below is the one I keep coming back to.

What I used to do vs what I do now

AWS / Docker
• Write the Dockerfile
• Stand up a database by hand
• Wire up the pipeline
• An afternoon, if it goes well
Railway
• Git push
railway add postgresql
• Pipeline's already there
• Live in under a minute

For a side project this is the difference between shipping it on a Sunday and not shipping it at all. For real production I'd still reach for more control, but most things aren't real production.

Setting it up

Railway reads your repo and figures out the framework on its own, so most of this is just glue. Here's the sequence I run for a new project:

# 1. Initialize Railway project
npm install -g @railway/cli
railway login
railway init

# 2. Link GitHub repository
railway connect

# 3. Add PostgreSQL database (one command!)
railway add postgresql

# 4. Configure environment variables
railway variables set NODE_ENV=production
railway variables set DATABASE_URL=${{PGHOST}}:${{PGPORT}}/${{PGDATABASE}}
railway variables set SECRET_KEY=your-secret-key

# 5. Deploy with git push
git add .
git commit -m "Initial deployment"
git push origin main

# Railway automatically:
# - Detects your framework (React, Django, Express, etc.)
# - Builds your application
# - Sets up SSL certificate
# - Deploys to global CDN
# - Provides custom domain

It's not magic and it's not for everything. The build minutes add up if you leave a service running idle, and the logging is fine until you actually need to debug something, at which point you'll wish for more. But for getting a thing from my laptop onto a URL someone else can open, nothing else I've used gets out of the way this fast. That's the whole pitch.