Overview
This guide covers deploying the Los Inmaduros Backend to production environments. The application is Docker-ready and can be deployed to any platform that supports Node.js or containers.Before You Deploy
Configure environment variables
Configure environment variables
Set all required environment variables in your deployment platform. See Environment Variables for details.Required variables:
NODE_ENV=productionDATABASE_URLCLERK_SECRET_KEY(usesk_live_...for production)CLERK_PUBLISHABLE_KEY(usepk_live_...for production)SUPABASE_URLSUPABASE_ANON_KEYFRONTEND_URL(your production frontend URL)
Set up PostgreSQL database
Set up PostgreSQL database
You’ll need a production PostgreSQL database. Options include:
- Render PostgreSQL (free tier available)
- Supabase Database (generous free tier)
- Railway PostgreSQL
- AWS RDS
- Google Cloud SQL
Configure Clerk for production
Configure Clerk for production
- Go to Clerk Dashboard
- Switch to your production instance or create one
- Copy your production keys (
sk_live_...andpk_live_...) - Configure your production domain in Clerk settings
Set up Supabase Storage
Set up Supabase Storage
- Create a production project in Supabase
- Create a storage bucket for photos
- Configure bucket policies for public access
- Copy your production URL and anon key
Recommended Platforms
Render (Recommended)
Render offers a free tier with automatic Docker deployments and managed PostgreSQL.Create a new Web Service
- Go to Render Dashboard
- Click “New” → “Web Service”
- Connect your GitHub repository
- Render automatically detects the
Dockerfile
Configure the service
- Name:
los-inmaduros-backend - Environment:
Docker - Region: Choose closest to your users
- Instance Type: Free tier or Starter ($7/month)
Create PostgreSQL database
- In Render Dashboard, click “New” → “PostgreSQL”
- Choose free tier or paid
- Copy the “Internal Database URL”
- Add to your web service environment variables:
Railway
Railway provides a simple deployment experience with automatic scaling.Create new project
- Go to Railway
- Click “New Project” → “Deploy from GitHub repo”
- Select your repository
Add PostgreSQL
- Click “New” → “Database” → “Add PostgreSQL”
- Railway generates
DATABASE_URLautomatically - No manual configuration needed
Configure environment variables
- Click on your service → “Variables”
- Add all required variables
- Use “Raw Editor” for bulk import:
Fly.io
Fly.io runs your app close to users with global distribution.Docker Production Deployment
If deploying to a platform that supports Docker Compose:Production Docker Compose
Thedocker-compose.prod.yml includes:
- Multi-stage Dockerfile build for smaller images
- Production-only dependencies
- Optimized restart policies
- Environment variable placeholders
- Automatic migrations on startup
Database Migrations
Migrations run automatically on startup via the Docker command:Manual Migration
If you need to run migrations manually:Security Best Practices
Environment Variables
- Use production Clerk keys (
sk_live_...,pk_live_...) - Never commit
.envfiles to version control - Use platform-provided secrets management
- Rotate credentials regularly
CORS Configuration
Rate Limiting
The backend includes built-in rate limiting:- General requests: 100 requests / 15 minutes per IP
- Authentication: 5 requests / 15 minutes per IP
- Resource creation: 20 requests / 15 minutes per IP
src/shared/middlewares/rate-limit.middleware.ts.
File Upload Security
- 5MB maximum file size
- Allowed formats: JPEG, PNG, GIF, WebP only
- Filename sanitization (prevents path traversal)
- MIME type validation
Database Security
- Use strong, randomly generated passwords
- Enable SSL connections (
?sslmode=require) - Regular backups (most platforms do this automatically)
- Limit database user permissions
HTTPS
All recommended platforms (Render, Railway, Fly.io) provide automatic HTTPS with Let’s Encrypt certificates.Performance Optimization
Database Connection Pooling
Prisma handles connection pooling automatically. For high-traffic applications:Caching
Consider adding Redis for caching frequently accessed data:- Route listings
- User profiles
- Meetup data
CDN for Images
Supabase Storage includes built-in CDN. Enable image transformations:Monitoring and Logging
Error Tracking
Consider integrating:- Sentry for error tracking
- LogRocket for session replay
- Platform-native logging (Render Logs, Railway Logs, etc.)
Health Checks
Most platforms support health check endpoints. The API root/ returns:
Uptime Monitoring
Use services like:- UptimeRobot (free)
- Pingdom
- Better Uptime
Post-Deployment Checklist
Troubleshooting
Application won’t start
Check logs for missing environment variables:Database connection failed
VerifyDATABASE_URL format:
Migrations failing
Reset and redeploy:CORS errors from frontend
EnsureFRONTEND_URL exactly matches your frontend:
Scaling Considerations
Horizontal Scaling
Most platforms support automatic scaling:- Render: Upgrade to Standard plan ($25/month) for auto-scaling
- Railway: Automatic scaling based on load
- Fly.io:
fly scale count 2to run 2 instances
Database Scaling
For high traffic:- Enable read replicas
- Use connection pooling (PgBouncer)
- Consider managed databases (AWS RDS, Google Cloud SQL)
Vertical Scaling
Increase instance resources:- Render: Upgrade to larger instance types
- Railway: Automatically scales resources
- Fly.io: Modify
fly.tomlVM size
Cost Estimates
Free Tier (Development/Testing)
- Render: Free web service + free PostgreSQL
- Railway: $5/month credit (enough for small apps)
- Supabase: 500MB storage, 2GB bandwidth
- Clerk: 10,000 monthly active users
Production (Low Traffic)
- Render: Starter web service (7)
- Supabase: Free tier sufficient
- Clerk: Free tier sufficient
Production (Medium Traffic)
- Render: Standard web service (20)
- Supabase: Pro plan ($25)
- Clerk: Pro plan ($25)
Next Steps
Environment Variables
Review all required environment variables
Docker Deployment
Learn about Docker configuration
API Reference
Explore the API endpoints
Authentication
Configure Clerk authentication
