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. Next.js অ্যাপ Docker-এ
DockerAdvanced

Next.js অ্যাপ Docker-এ

Next.js standalone output দিয়ে ছোট ও দ্রুত production image — multi-stage build — বাংলায়।

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

Next.js-কে Docker-এ চালাতে `output: "standalone"` ব্যবহার করা ভালো — এটি সব প্রয়োজনীয় runtime file একটি ছোট folder-এ রাখে; ফলে image অনেক হালকা হয়।

next.config.ts-এ standalone

next.configts
ts
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  output: "standalone",
};

export default nextConfig;

Multi-stage Dockerfile

Dockerfiledockerfile
dockerfile
# Stage 1: 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 AS runner
WORKDIR /app

ENV NODE_ENV=production

# standalone output file-গুলোই প্রয়োজন
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public

EXPOSE 3000
USER node

CMD ["node", "server.js"]

Build ও verify

Run stepsbash
bash
docker build -t my-next-app .

docker run -d -p 3000:3000 \
  -e DATABASE_URL=mongodb://... \
  --name next-app \
  my-next-app

# homepage check
curl -I http://localhost:3000

with Docker-এর বিশেষ ভুল

  • .next ও node_modules-কে .dockerignore-এ রাখুন
  • output: standalone ছাড়া সব file কপি করলে image ভারী হয়
  • প্রতি পরিবর্তনে cache ভাঙা আটকাতে COPY package*.json আলাদা ধাপে দিন
  • Dev mode-এ live reload চাইলে bind mount + npm run dev ব্যবহার করুন
.dockerignoretext
text
node_modules
.next
.git
.env
.env.*
Dockerfile
.dockerignore
Trailing advice

Static export (SSG-only) হলে image-এ এই ছোট force standalone দরকার নয় — next export output-কে nginx-এর মতো web server-এ serve করুন। ...না হলে সেটাও সম্ভব।

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

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

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

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

mdanamolhasan1998@gmail.com