This guide explains how to deploy InterviewLab to Railway with multiple services:
- API Service: FastAPI backend
- Agent Service: LiveKit agent (optional, can run separately)
- Railway account: railway.app
- GitHub repository connected
- Railway CLI installed:
npm i -g @railway/cli
railway login
railway initrailway add postgresqlRailway automatically sets DATABASE_URL environment variable.
railway add redisRailway automatically sets REDIS_URL environment variable.
- Go to Railway dashboard
- Click "New Service" → "GitHub Repo"
- Select your repository
- Railway will detect
railway.jsonautomatically - Set environment variables (see below)
railway link
railway upIn Railway dashboard → Variables, set:
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
Auto-set by PostgreSQL service | postgresql://... |
REDIS_URL |
Auto-set by Redis service | redis://... |
SECRET_KEY |
JWT secret key | Generate: openssl rand -hex 32 |
OPENAI_API_KEY |
OpenAI API key | sk-... |
LIVEKIT_URL |
LiveKit server URL | wss://your-project.livekit.cloud |
LIVEKIT_API_KEY |
LiveKit API key | ... |
LIVEKIT_API_SECRET |
LiveKit API secret | ... |
ENVIRONMENT |
Environment name | production |
LOG_LEVEL |
Logging level | INFO |
CORS_ORIGINS |
Allowed origins | https://your-frontend.vercel.app |
The agent can run on Railway or separately.
- Create new service:
railway service create interview-agent(or name itagent) - Link to same project:
railway link - IMPORTANT: Configure the service manually in Railway dashboard:
- Go to Railway dashboard → Agent service → Settings → Deploy
- Set Start Command to:
python -m src.agents.interview_agent start - Disable Healthcheck: Go to Settings → Healthcheck and disable it (LiveKit agents don't expose HTTP endpoints)
- The service uses
Dockerfile.agentwhich doesn't include a healthcheck - This ensures it uses the agent instead of the FastAPI server
- Set same environment variables as API (especially LiveKit credentials)
- Deploy:
railway up
Note: Railway may not automatically detect railway-agent.json. Always verify:
- The start command in the dashboard matches the agent command above
- Healthcheck is disabled (agents connect via WebSocket, not HTTP)
Deploy agent separately (e.g., on a VPS) for better isolation.
Migrations run automatically on startup (see railway.json startCommand).
To run manually:
railway run alembic upgrade head- Railway dashboard → Settings → Generate Domain
- Note the domain:
your-app.railway.app - Update frontend
NEXT_PUBLIC_API_URLto point to this domain
- Builds from Dockerfile
- Runs migrations on startup
- Starts uvicorn server
- Health check on
/health
- Builds from same Dockerfile
- Starts LiveKit agent
- Requires same environment variables
Default Railway configuration:
- CPU: 1.0 vCPU
- Memory: 2GB
- Disk: 10GB
Adjust in Railway dashboard → Settings → Resources.
- Logs: Railway dashboard → Logs
- Metrics: Railway dashboard → Metrics
- Health:
https://your-app.railway.app/health
| Issue | Solution |
|---|---|
| Build fails | Check Dockerfile, verify dependencies |
| Database connection error | Verify DATABASE_URL is set |
| Agent won't connect | Check LiveKit credentials |
| High memory usage | Increase memory limit or optimize code |
| Port binding error | Ensure using $PORT environment variable |
- Deployment Guide - Detailed deployment instructions
- Local Development - Development setup