- Docker and Docker Compose
- MongoDB (local or cloud)
- Redis (local or cloud)
- Domain name with SSL certificate (recommended)
Create a .env file:
# Application
NODE_ENV=production
PORT=5000
# Database
MONGODB_URI=mongodb://localhost:27017/rce_backend
REDIS_URL=redis://localhost:6379
# Security
JWT_SECRET=your_super_secret_jwt_key_here_min_256_bits
BCRYPT_ROUNDS=12
# CORS
ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
# Rate Limiting
GENERAL_RATE_LIMIT=100
AUTH_RATE_LIMIT=5
EXECUTION_RATE_LIMIT=10
# Docker
DOCKER_HOST=unix:///var/run/docker.sock- Build executor images:
chmod +x scripts/build-executors.sh
./scripts/build-executors.sh- Deploy with Docker Compose:
chmod +x deploy-production.sh
./deploy-production.sh- Install dependencies:
yarn install --production- Build the application:
yarn build- Start the application:
yarn startserver {
listen 80;
server_name yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name yourdomain.com;
ssl_certificate /path/to/your/certificate.crt;
ssl_certificate_key /path/to/your/private.key;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}- Firewall: Only allow necessary ports (80, 443, 22)
- Docker Security: Run containers as non-root users
- Rate Limiting: Implement proper rate limiting
- Input Validation: Validate all user inputs
- Logging: Monitor and log all activities
- Updates: Keep all dependencies updated
- Health Check:
GET /health - Logs: Check
logs/directory - Docker Stats: Monitor container resource usage
- Database: Monitor MongoDB and Redis performance
- Database Backup:
mongodump --uri="$MONGODB_URI" --out=backup/$(date +%Y%m%d)- Redis Backup:
redis-cli --rdb dump.rdbFor high-traffic scenarios:
- Horizontal Scaling: Use multiple application instances
- Load Balancer: Distribute traffic across instances
- Database Sharding: Scale MongoDB horizontally
- Redis Cluster: Use Redis cluster for caching
- Container Orchestration: Consider Kubernetes for large-scale deployments