Cloud Platform Deployment
Deploy SaleSpider to popular cloud platforms for scalable, managed hosting.
Overview
Cloud platform deployment provides:
- Automatic scaling
- Managed infrastructure
- CI/CD integration
- Global CDN
- Zero-downtime deployments
Automatic Setup
Most platforms automatically run migrations and seeding when using npm run start:prod. Vercel requires manual seeding (see below).
Supported Platforms
- Vercel - Best for Next.js applications
- Railway - All-in-one with database included
- Render - Simple deployments with free tier
- Fly.io - Global edge deployment
- DigitalOcean App Platform - Managed containers
- Any platform supporting Node.js 24+ and Docker
Vercel Deployment
Prerequisites
- Vercel account
- GitHub/GitLab/Bitbucket repository
- Hosted PostgreSQL database (Neon, Supabase, etc.)
Quick Deploy
Connect Repository
- Go to vercel.com
- Click "New Project"
- Import your Git repository
Configure Build Settings
Framework Preset: Next.js Build Command: npm run build Output Directory: .next Install Command: npm installSet Environment Variables
bashDATABASE_URL=postgresql://user:pass@host/db JWT_SECRET=your-secret-key JWT_EXPIRES_IN=7d GOOGLE_GENAI_API_KEY=your-api-key NEXT_PUBLIC_APP_URL=https://your-app.vercel.app SETUP_BACKUP=falseDeploy
- Click "Deploy"
- Wait for build to complete
- Access your app at the provided URL
Manual Seeding Required
Vercel requires one-time manual seeding after first deployment:
bashexport DATABASE_URL="postgresql://..." npm run seed:prod
Custom Domain
- Go to Project Settings → Domains
- Add your custom domain
- Configure DNS records as instructed
- Update
NEXT_PUBLIC_APP_URLenvironment variable
Automatic Deployments
Vercel automatically deploys:
- Production: Pushes to
mainbranch - Preview: Pull requests and other branches
Railway Deployment
Prerequisites
- Railway account
- GitHub repository
Quick Deploy
Create Project
- Go to railway.app
- Click "New Project"
- Select "Deploy from GitHub"
Add Database
- Click "New" → "Database" → "PostgreSQL"
- Railway automatically sets
DATABASE_URL
Configure Service
bash# Railway auto-sets DATABASE_URL JWT_SECRET=your-secret-key JWT_EXPIRES_IN=7d GOOGLE_GENAI_API_KEY=your-api-key NEXT_PUBLIC_APP_URL=${{RAILWAY_PUBLIC_DOMAIN}} SETUP_BACKUP=falseSet Build Settings
Build Command: npm run build Start Command: npm run start:prodDeploy
- Railway automatically builds and deploys
- Migrations and seeding run automatically on startup
- Access via generated railway.app domain
Custom Domain
- Go to Settings → Networking
- Add custom domain
- Configure DNS CNAME record
- SSL automatically provisioned
Render Deployment
Prerequisites
- Render account
- GitHub/GitLab repository
- Hosted PostgreSQL database
Quick Deploy
Create Web Service
- Go to render.com
- Click "New" → "Web Service"
- Connect repository
Configure Service
Name: salespider Environment: Node Build Command: npm run build Start Command: npm run start:prodSet Environment Variables
bashDATABASE_URL=postgresql://user:pass@host/db JWT_SECRET=your-secret-key JWT_EXPIRES_IN=7d GOOGLE_GENAI_API_KEY=your-api-key NEXT_PUBLIC_APP_URL=https://your-app.onrender.com SETUP_BACKUP=false NODE_ENV=productionDeploy
- Click "Create Web Service"
- Wait for deployment
- Access via onrender.com URL
Add Database
- Click "New" → "PostgreSQL"
- Copy internal connection string
- Update
DATABASE_URLin web service
Fly.io Deployment
Prerequisites
- Fly.io account
- Fly CLI installed
Quick Deploy
Install Fly CLI
bash# macOS brew install flyctl # Linux curl -L https://fly.io/install.sh | sh # Windows iwr https://fly.io/install.ps1 -useb | iexLogin
bashfly auth loginInitialize App
bashfly launchSet Secrets
bashfly secrets set \ DATABASE_URL="postgresql://user:pass@host/db" \ JWT_SECRET="your-secret-key" \ GOOGLE_GENAI_API_KEY="your-api-key"Configure Start Command
Create or update
fly.toml:toml[processes] app = "npm run start:prod"Deploy
bashfly deploy
Add PostgreSQL
# Create Postgres cluster
fly postgres create
# Attach to app
fly postgres attach <postgres-app-name>DigitalOcean App Platform
Prerequisites
- DigitalOcean account
- GitHub repository
Quick Deploy
Create App
- Go to Apps → Create App
- Connect GitHub repository
Configure Component
Type: Web Service Build Command: npm run build Run Command: npm run start:prod HTTP Port: 3000Add Database
- Add Component → Database
- Select PostgreSQL
- Connection details auto-configured
Set Environment Variables
bashDATABASE_URL=${db.DATABASE_URL} JWT_SECRET=your-secret-key JWT_EXPIRES_IN=7d GOOGLE_GENAI_API_KEY=your-api-key NEXT_PUBLIC_APP_URL=${APP_URL} SETUP_BACKUP=falseDeploy
- Click "Create Resources"
- Wait for deployment
Environment Variables
Required Variables
All platforms need these:
# Database
DATABASE_URL=postgresql://user:pass@host/db
# Authentication
JWT_SECRET=your-super-secret-key
JWT_EXPIRES_IN=7d
# Application
NODE_ENV=production
NEXT_PUBLIC_APP_URL=https://your-domain.com
# Disable local backups
SETUP_BACKUP=false
PGBACKREST_REPO1_TYPE=noneOptional Variables
# AI Features
GOOGLE_GENAI_API_KEY=your-api-key
# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_MAX_REQUESTS=100
RATE_LIMIT_WINDOW_MS=900000Database Setup
Recommended Providers
For cloud deployments, use:
Neon - Serverless PostgreSQL
- Free tier available
- Automatic scaling
- Branch databases
Supabase - PostgreSQL with extras
- Free tier available
- Built-in auth (optional)
- Real-time features
Railway - Integrated database
- Included with platform
- Automatic backups
- Simple setup
Learn more about hosted databases →
CI/CD Integration
GitHub Actions
Create .github/workflows/deploy.yml:
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "24"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}GitLab CI
Create .gitlab-ci.yml:
stages:
- test
- build
- deploy
test:
stage: test
script:
- npm ci
- npm test
build:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths:
- .next/
deploy:
stage: deploy
script:
- npm run deploy
only:
- mainMonitoring
Platform Monitoring
Most platforms provide:
- Request logs
- Error tracking
- Performance metrics
- Resource usage
External Monitoring
Consider adding:
- Sentry - Error tracking
- LogRocket - Session replay
- Datadog - APM and logs
- New Relic - Performance monitoring
Troubleshooting
Build Failures
# Check build logs
# Verify Node.js version
# Check environment variables
# Test build locally
npm run buildRuntime Errors
# Check application logs
# Verify database connection
# Check environment variables
# Test locally with production build
npm run build && npm startDatabase Connection Issues
# Verify DATABASE_URL format
# Check SSL requirements
# Test connection locally
# Check firewall rulesMigration Between Platforms
Export from Current Platform
- Export environment variables
- Backup database
- Download code (if needed)
Import to New Platform
- Create new project
- Import repository
- Set environment variables
- Restore database
- Deploy
Comparison
| Feature | Vercel | Railway | Render | Fly.io |
|---|---|---|---|---|
| Free Tier | ✅ | $5 credit | ✅ | ✅ |
| Database Included | ❌ | ✅ | ✅ | ✅ |
| Auto Scaling | ✅ | ✅ | ✅ | ✅ |
| Custom Domains | ✅ | ✅ | ✅ | ✅ |
| CI/CD | ✅ | ✅ | ✅ | ✅ |
| Edge Network | ✅ | ❌ | ❌ | ✅ |