Backend Deployment
Backend Deployment
Guide to deploying the backend API server.
Prerequisites
- Node.js 18+
- pnpm or npm
- Environment variables configured
Build
cd backendpnpm installpnpm run buildEnvironment Variables
Set all required environment variables:
PORT=3001WS_PORT=3002CORS_ORIGIN=https://your-frontend-domain.comDATABASE_PATH=./data/arena.jsonGROQ_API_KEY=your_key# ... other variablesDeployment Options
PM2
pm2 start dist/index.js --name ai-arena-backendDocker
Create Dockerfile:
FROM node:18-alpineWORKDIR /appCOPY package*.json ./RUN npm installCOPY . .RUN npm run buildEXPOSE 3001 3002CMD ["node", "dist/index.js"]Cloud Platforms
- Railway: Connect GitHub repo
- Render: Connect GitHub repo
- Fly.io: Use fly CLI
- AWS/GCP/Azure: Use container services
Health Checks
The backend provides health check endpoint:
GET /healthNext Steps
- Frontend Deployment - Frontend setup