diff --git a/Dockerfile b/Dockerfile index 4094a32..3504ccf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,28 +2,27 @@ FROM node:18-alpine AS deps WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN npm ci -# 2단계: 소스 빌드 +# 2단계: 빌드 (standalone 모드) FROM node:18-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules -COPY . . -RUN npm run build +COPY . . + +# Next.js standalone 빌드 생성 +RUN npm run build # 3단계: 프로덕션 실행 환경 FROM node:18-alpine AS runner WORKDIR /app ENV NODE_ENV production -# 프로덕션 의존성만 재설치 -COPY package*.json ./ -RUN npm ci --only=production - -# 빌드 결과물만 복사 -COPY --from=builder /app/.next ./.next +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/public ./public -COPY --from=builder /app/next.config.mjs ./ EXPOSE 3000 -CMD ["npm", "start"] \ No newline at end of file +ENV PORT 3000 + +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index 1d61478..4ce46f8 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,4 +1,6 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {} +const nextConfig = { + output: 'standalone', +} export default nextConfig