Deploying Node.js and NestJS applications to production requires container environments optimized for security, minimal resource footprint, and graceful termination.
1. Security First: Non-Root Execution
Running Node.js processes as non-root `node` users inside containers prevents privilege escalation vulnerabilities in host environments.
2. Graceful Shutdown & SIGTERM Signals
Handling `process.on('SIGTERM')` signals in NestJS applications allows active database connections and HTTP requests to complete before pods terminate.
3. Kubernetes Liveness & Readiness Probes
Exposing dedicated `/health/liveness` and `/health/readiness` endpoints allows Kubernetes controllers to auto-heal unresponsive pod instances.
