Overview
This guide covers deploying DeelRx CRM using Docker and Kubernetes across different environments. The application is containerized for maximum flexibility and can be deployed on various platforms.Prerequisites
- Docker 20.10+
- Docker Compose 2.0+
- Kubernetes 1.20+ (for K8s deployment)
- kubectl (for K8s deployment)
- pnpm (for local development)
Quick Start
Local Development
Access Services
- Main App: http://localhost:3000
- API: http://localhost:3001
- Docs: http://localhost:3004
- pgAdmin: http://localhost:5050
- Redis Admin: http://localhost:8001
Production Deployment
Docker Configuration
Multi-Stage Builds
The Dockerfiles use multi-stage builds for optimal image sizes:- Base: Node.js 20 Alpine with pnpm
- Dependencies: Install all dependencies
- Builder: Build the application
- Production: Minimal runtime image
Image Structure
Development vs Production
| Aspect | Development | Production |
|---|---|---|
| Base Image | node:20-alpine | node:20-alpine |
| Dependencies | All (dev + prod) | Production only |
| Build Cache | Enabled | Disabled |
| Hot Reload | Yes | No |
| Health Checks | Basic | Comprehensive |
| Security | Relaxed | Strict |
Environment Configuration
Environment Variables
Required Variables
Optional Variables
Docker Compose Environments
Development (docker-compose.dev.yml)
- Hot reload enabled
- Development dependencies included
- Admin tools (pgAdmin, RedisInsight)
- Volume mounts for live code changes
Production (docker-compose.yml)
- Optimized for performance
- Security hardening
- Health checks
- Resource limits
- Nginx reverse proxy
Kubernetes Deployment
Prerequisites
Scaling
Horizontal Pod Autoscaler
Vertical Pod Autoscaler
Monitoring and Observability
Health Checks
All services include comprehensive health checks:- Liveness Probe: Ensures container is running
- Readiness Probe: Ensures service is ready to accept traffic
- Startup Probe: Ensures slow-starting containers have time to initialize
Logging
Metrics
Security Considerations
Container Security
- All containers run as non-root user
- Production containers use read-only filesystem
- CPU and memory limits prevent resource exhaustion
- Restricted capabilities and permissions
Network Security
- Network policies restrict inter-pod communication
- SSL/TLS at ingress level
- Optional Istio integration for advanced networking
Secrets Management
- Kubernetes secrets encrypted at rest
- Integration with HashiCorp Vault or AWS Secrets Manager
- Automated secret rotation policies
Performance Optimization
Resource Allocation
| Service | CPU Request | CPU Limit | Memory Request | Memory Limit |
|---|---|---|---|---|
| App | 250m | 500m | 512Mi | 1Gi |
| API | 200m | 400m | 256Mi | 512Mi |
| Docs | 100m | 200m | 128Mi | 256Mi |
| PostgreSQL | 250m | 500m | 256Mi | 512Mi |
| Redis | 100m | 200m | 128Mi | 256Mi |
Caching Strategy
- Redis clustering for high availability
- CDN integration for static asset caching
- Database connection pooling for optimized connection management
Troubleshooting
Common Issues
Container Won't Start
Container Won't Start
Database Connection Issues
Database Connection Issues
Memory Issues
Memory Issues
Debug Commands
Backup and Recovery
Database Backups
Volume Snapshots
Migration Strategies
Zero-Downtime Deployment
- Blue-Green deployment for switching traffic between versions
- Rolling updates for gradual pod replacement
- Canary releases for gradual traffic shifting
Database Migrations
Cost Optimization
Resource Right-Sizing
- Monitor usage to determine optimal resource allocation
- Implement HPA and VPA for dynamic scaling
- Use spot instances for non-critical workloads
Storage Optimization
- Regular automated snapshots
- Automated cleanup of old logs and data
- Enable compression for stored data
Support and Maintenance
Regular Maintenance
- Regular base image updates for security
- Keep dependencies current
- Regular backup testing
Monitoring
- Real-time service health dashboards
- Proactive issue detection with alerting
- Continuous performance monitoring
Next Steps
CI/CD Integration
Set up automated deployment pipelines for continuous delivery.
Service Mesh
Implement advanced networking and security with Istio.
Multi-Region
Deploy across multiple regions for geographic resilience.
Disaster Recovery
Implement comprehensive backup and recovery procedures.