Deploy to Railway
Railway provides easy deployment with easy PostgreSQL hosting.
Quick Deploy
1. Fork the Repository
Fork github.com/jmynes/punt to your GitHub account.
2. Create Railway Project
- Go to railway.app and sign in
- Click New Project
- Select Deploy from GitHub repo
- Choose your forked PUNT repository
3. Configure Environment Variables
Add the following environment variables in Railway:
| Variable | Value |
|---|---|
AUTH_SECRET | Generate with openssl rand -base64 32 |
DATABASE_URL | PostgreSQL connection string (provided by Railway PostgreSQL plugin) |
AUTH_TRUST_HOST | true |
4. Add PostgreSQL Plugin
PUNT requires a PostgreSQL database:
- In your Railway project, click + New
- Select Database → PostgreSQL
- Railway will provision a PostgreSQL instance and automatically set
DATABASE_URLin your service environment
5. Deploy
Railway will automatically:
- Detect the Nixpacks configuration
- Install dependencies with pnpm
- Build the Next.js application
- Start the production server
Configuration Files
PUNT includes Railway-specific configuration:
railway.toml
[build]
builder = "NIXPACKS"
[deploy]
startCommand = "pnpm start"
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 3
.node-version
Specifies Node.js 20 (required by Next.js 16).
Environment Variables Reference
Required
| Variable | Description |
|---|---|
AUTH_SECRET | JWT signing secret |
DATABASE_URL | PostgreSQL connection string |
AUTH_TRUST_HOST | Trust Railway's proxy |
Optional
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 3000 (Railway sets this) |
TRUST_PROXY | Trust X-Forwarded-For | true recommended |
Demo Mode Deployment
For a demo/preview deployment without persistence:
NEXT_PUBLIC_DEMO_MODE=true
AUTH_SECRET=any-secret-value
AUTH_TRUST_HOST=true
Demo mode runs entirely client-side with localStorage, so no database is required.
This runs entirely client-side with localStorage.
Custom Domain
Add Custom Domain
- Go to your Railway service settings
- Click Settings → Networking
- Add your custom domain
- Configure DNS as instructed
Railway provides free HTTPS certificates via Let's Encrypt.
Troubleshooting
Database Errors
If you see Prisma errors on startup:
- Ensure the volume is mounted at
/app/data - Check
DATABASE_URLpoints to the mounted volume - The database file is created automatically on first run
Build Failures
Check that:
- Node.js 20+ is being used (
.node-versionfile) - pnpm is available (Railway uses Nixpacks which supports pnpm)
Memory Issues
If the build runs out of memory:
- Go to service settings
- Increase memory limit
- Redeploy
Monitoring
View Logs
- Go to your Railway service
- Click Deployments
- Select a deployment to view logs
Metrics
Railway provides built-in metrics:
- CPU usage
- Memory usage
- Network traffic
Scaling
Upgrade Plan
Railway's free tier includes:
- 500 hours of runtime per month
- 1GB persistent storage
For production use, consider the Developer plan for:
- Unlimited runtime
- More storage
- Custom domains
Volume Size
Increase volume size in Railway settings if needed:
- Go to the Volume
- Click Settings
- Adjust size
Backup
Export Database
Use PUNT's built-in export:
- Log in as admin
- Go to Admin Panel → Database
- Click Export
Manual Backup
SSH into Railway (requires Pro plan) or use Railway CLI:
railway run pg_dump $DATABASE_URL > backup.sql
Updates
Deploy Updates
When you push to your repository:
- Railway detects the change
- Builds automatically
- Zero-downtime deployment
Manual Redeploy
- Go to your Railway service
- Click Deployments
- Click Redeploy