Build and Deployment
How do I create a production build?
How do I create a production build?
API server build:Build output is generated in the Build output is generated in the
api/dist directory.Web frontend build:web/dist directory.How do I run in a production environment?
How do I run in a production environment?
API server:Or using PM2:Web server:Serve static files with Nginx or Apache:
Environment Variables
How do I set environment variables?
How do I set environment variables?
Create .env file:Use in sonamu.config.ts:
How do I securely manage sensitive information?
How do I securely manage sensitive information?
Method 1: Environment VariablesMethod 2: Secret Management Tools
- AWS Secrets Manager
- HashiCorp Vault
- Azure Key Vault
Database
How do I run production database migrations?
How do I run production database migrations?
1. Check migration status:2. Test on Shadow DB (recommended):3. Apply to actual DB:4. Rollback (if needed):
How do I set up database backups?
How do I set up database backups?
PostgreSQL backup:Automatic backup (Cron):
Monitoring and Logging
How do I set up logging?
How do I set up logging?
Using Winston:Using the logger:
How do I create a health check endpoint?
How do I create a health check endpoint?
How do I set up error monitoring?
How do I set up error monitoring?
Sentry integration:
Performance Optimization
How do I optimize production performance?
How do I optimize production performance?
1. Connection Pool settings:2. Enable caching:3. Enable compression:
How do I set up static file caching?
How do I set up static file caching?
Nginx configuration:
Docker
How do I deploy with Docker?
How do I deploy with Docker?
Create Dockerfile:docker-compose.yml:Run:
CI/CD
How do I set up automatic deployment with GitHub Actions?
How do I set up automatic deployment with GitHub Actions?
.github/workflows/deploy.yml:
Security
How do I set up HTTPS?
How do I set up HTTPS?
Letβs Encrypt + Nginx:Nginx HTTPS configuration:
How do I configure CORS?
How do I configure CORS?
How do I set up Rate Limiting?
How do I set up Rate Limiting?
Best Practices
Production checklist
Production checklist
Security:
- HTTPS configured
- Sensitive info managed via environment variables
- CORS properly configured
- Rate Limiting set up
- SQL Injection prevention (using Puri)
- XSS prevention (input validation)
- Connection Pool optimized
- Redis caching enabled
- Static file caching
- DB indexes optimized
- N+1 queries eliminated
- Health check endpoint
- Error monitoring (Sentry)
- Log collection (Winston)
- DB backup automation
- Production environment variables set
- Migration tested (Shadow DB)
- CI/CD pipeline
- Rollback plan