Deployment Options
PrivyCode server can be deployed using multiple methods:Railway
One-click deployment with Railway (Recommended)
Docker
Deploy anywhere using Docker containers
VPS
Deploy on any VPS (DigitalOcean, AWS, etc.)
Fly.io
Deploy on Fly.io with automatic scaling
Deploy with Railway (Recommended)
Railway provides the easiest deployment experience with automatic builds and PostgreSQL provisioning.Create a Railway account
Visit Railway and sign up with your GitHub account.
Add PostgreSQL database
In your Railway project:
- Click New → Database → Add PostgreSQL
- Railway will automatically provision a PostgreSQL instance
- The
DATABASE_URLwill be automatically injected as an environment variable
Update GitHub OAuth callback URL
Go to your GitHub OAuth App settings and update:
- Homepage URL: Your frontend production URL
- Authorization callback URL:
https://your-app.railway.app/github/callback
Deploy
Railway will automatically deploy your app. You can monitor the build logs in the Deployments tab.
Your app will be available at
https://your-app.railway.appRailway Configuration File
The repository includes arailway.json configuration file:
railway.json
Deploy with Docker
PrivyCode includes a production-ready Dockerfile using multi-stage builds for optimal image size.Dockerfile Overview
Dockerfile
This multi-stage build:
- Uses
golang:1.23-alpinefor building (small base image) - Compiles a static binary with
CGO_ENABLED=0 - Uses
alpine:latestfor the final image (only ~5MB base) - Results in a final image size of ~20MB
Build and Run with Docker
Docker Compose (Full Stack)
For a complete setup with PostgreSQL:docker-compose.yml
Deploy on VPS (DigitalOcean, AWS, etc.)
Set up your VPS
- Create a VPS instance (Ubuntu 22.04 recommended)
- SSH into your server
- Install Docker:
Set up PostgreSQL
Option 1: Use a managed database (recommended)
- DigitalOcean Managed Databases
- AWS RDS
- Supabase PostgreSQL
Create .env file
Post-Deployment Checklist
Update CORS allowed origins
If your frontend is on a different domain, verify it’s in the CORS middleware:
internal/middleware/cors.go
Troubleshooting
Database connection errors
Database connection errors
- Verify
DATABASE_URLformat is correct - Check if database is accessible from your server
- For Railway: ensure PostgreSQL service is linked
- Check SSL mode settings (
sslmode=requirefor production)
GitHub OAuth not working
GitHub OAuth not working
- Verify callback URL matches exactly (including https://)
- Check if
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETare correct - Ensure your domain is not blocked by GitHub
CORS errors from frontend
CORS errors from frontend
- Add your frontend domain to
internal/middleware/cors.go - Rebuild and redeploy after changing CORS settings
- Verify
FRONTEND_URLenvironment variable is correct
Container exits immediately
Container exits immediately
Check logs for errors:Common issues:
- Missing required environment variables
- Database connection failure
- Port already in use
Next Steps
Environment Variables
Complete reference for all configuration options
API Reference
Explore available endpoints
Setup Guide
Local development setup
Security
Production security best practices