add docker

This commit is contained in:
AmirHossein Mahmoodi
2025-05-05 14:34:39 +03:30
parent a9dabf944b
commit 4b6b87f8e9
2 changed files with 46 additions and 0 deletions

33
Dockerfile Normal file
View File

@@ -0,0 +1,33 @@
FROM node:22-alpine AS builder
WORKDIR /app
RUN npm install -g pnpm
COPY pnpm-lock.yaml ./
COPY package.json ./
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN npm install -g pnpm
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/next.config.js ./next.config.js
COPY --from=builder /app/app ./app
EXPOSE 3000
CMD ["pnpm", "start"]

13
docker-compose.yml Normal file
View File

@@ -0,0 +1,13 @@
version: '3.8'
services:
nextjs:
build:
context: .
dockerfile: Dockerfile
container_name: nextjs-app
ports:
- "3000:3000"
env_file:
- .env.local
restart: unless-stopped