This project uses NGINX in both development and production for environment consistency.
Browser → http://localhost:4200 → NGINX Container (port 4200)
↓
Dev Server Container (port 4201)
- Two separate containers: NGINX and Angular dev server
- NGINX acts as reverse proxy
- Angular dev server provides HMR and live reload
- Same URL as before:
http://localhost:4200
Browser → http://localhost → NGINX (port 80) → Static Files
- Multi-stage build with optimized bundle
- NGINX serves pre-built static files
- Production optimizations enabled
docker-compose up --buildAccess: http://localhost:4200
Features:
- ✅ Hot Module Replacement (HMR)
- ✅ Live reload on file changes
- ✅ NGINX reverse proxy (environment consistency)
- ✅ WebSocket support for HMR
- ✅ Volume mounts for instant updates
docker-compose downdocker-compose logs -f frontenddocker-compose -f docker-compose.prod.yml up --buildAccess: http://localhost
Features:
- ✅ Optimized production build
- ✅ Gzip compression
- ✅ Static asset caching (1 year)
- ✅ Security headers
- ✅ SPA routing support
- ✅ Health check endpoint
docker-compose -f docker-compose.prod.yml downdocker build -f talent-management/Dockerfile.prod -t talent-management:prod ./talent-managementtalent-management/
├── Dockerfile # Angular dev server only
├── Dockerfile.nginx # NGINX container for development
├── Dockerfile.prod # Production multi-stage build
├── nginx.dev.conf # NGINX config for development (proxy)
├── nginx.prod.conf # NGINX config for production (static)
├── docker-compose.yml # Development compose (2 services)
└── docker-compose.prod.yml # Production compose
dev-server (Dockerfile):
- Base Image: node:20-alpine
- Port: 4201 (internal only)
- Features: Angular dev server with HMR
nginx (Dockerfile.nginx):
- Base Image: nginx:alpine
- Port: 4200 (external access)
- Features: Reverse proxy with WebSocket support
- Stage 1: Build Angular app (node:20-alpine)
- Stage 2: Serve with NGINX (nginx:alpine)
- Port: 80
- Features: Optimized bundle, caching, compression
Both environments include health check endpoints:
# Development
curl http://localhost:4200/health
# Production
curl http://localhost/healthDevelopment (4200):
# Find process using port 4200
netstat -ano | findstr :4200
# Kill the process (replace PID)
taskkill /PID <PID> /FProduction (80):
# Find process using port 80
netstat -ano | findstr :80
# Kill the process (replace PID)
taskkill /PID <PID> /F# Development
docker-compose down
docker-compose build --no-cache
docker-compose up
# Production
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml build --no-cache
docker-compose -f docker-compose.prod.yml up# Access container
docker exec -it talent-management-angular sh
# View NGINX logs
cat /var/log/nginx/dev-access.log
cat /var/log/nginx/dev-error.log✅ Environment Consistency - Same NGINX in dev and prod
✅ Fast Development - HMR and live reload still work
✅ Early Issue Detection - Catch NGINX routing issues in dev
✅ Production Ready - Optimized bundle with proper caching
✅ No Workflow Changes - Still use http://localhost:4200 in dev
- Add SSL/HTTPS support for production
- Configure NGINX for API reverse proxy (if needed)
- Add Docker Compose integration with API and IdentityServer
- Set up CI/CD pipeline with Docker builds