पाठ 26 / 34

Deployment

NODE_ENV, process manager और health-check endpoints के साथ production में NestJS app build, configure और run करें।

Production के लिए build करें

Nest build से TypeScript को JavaScript में compile करें; output dist/ में जाता है। अंतिम image में केवल production dependencies install करें।

npm run build
ls dist/  # compiled JS output

Production में run करें

NODE_ENV=production सेट करें और compiled dist/main.js चलाएँ; वैकल्पिक रूप से PM2 जैसा process manager उपयोग करें।

NODE_ENV=production node dist/main.js

# or with PM2
pm2 start dist/main.js --name "nestjs-app"

Health check endpoint

Load balancers और orchestrators को poll करने के लिए /health या /ping endpoint जोड़ें।