Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Docker Documentation25টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Introduction
  • Containerization
  • Architecture
  • Installation
  • Images
  • Containers
  • Dockerfile
  • Volumes
  • Networks
  • Docker Compose
  • Environment Variables
  • Node.js + Docker
  • Next.js + Docker
  • Express.js + Docker
  • NestJS + Docker
  • Databases + Docker
  • Development Workflow
  • Production
  • Multi-stage Builds
  • Security
  • Optimization
  • CI/CD
  • Deployment
  • Real-world Project
  • Interview Questions
  1. Docs
  2. Docker
  3. NestJS অ্যাপ Docker-এ
DockerAdvanced

NestJS অ্যাপ Docker-এ

NestJS মাল্টি-stage docker build, production port ও PostgreSQL/Redis compose — বাংলায়।

10টি অংশবাংলা ভাষায়

NestJS TypeScript-ভিত্তিক — তাই build করে dist produce করতে হয় এবং production image-এ শুধু সেই output থাকে।

package.json scripts

scriptsjson
json
{
  "scripts": {
    "build": "nest build",
    "start": "node dist/main.js",
    "start:dev": "nest start --watch",
    "start:prod": "node dist/main.js"
  }
}

Multi-stage Dockerfile

Dockerfiledockerfile
dockerfile
# Stage 1: install + build
FROM node:20-alpine AS builder
WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .
RUN npm run build

# Stage 2: runtime
FROM node:20-alpine
WORKDIR /app

ENV NODE_ENV=production

# শুধু compiled output + production dependencies
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist

EXPOSE 3000
USER node

CMD ["node", "dist/main.js"]

PostgreSQL + Redis compose

compose.ymlyaml
yaml
services:
  api:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://postgres:pass@postgres:5432/nest
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:16-alpine
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=pass
      - POSTGRES_DB=nest
    volumes:
      - pg-data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine

volumes:
  pg-data:

Run

Run stepsbash
bash
docker compose up -d --build
docker compose logs -f api
curl http://localhost:3000/api
# migration (যদি থাকে)
docker compose exec api node dist/main.js migration:run
dist আর node_modules

Runtime stage-এ devDependencies কপি করবেন না — শুধু production dependencies রাখুন যাতে image হালকা ও নিরাপদ হয়।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরExpress.js অ্যাপ Docker-এপরেরMongoDB, PostgreSQL ও Redis Docker-এ
এই পেজে
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com