diff --git a/docker/deploy/frontend.Dockerfile b/docker/deploy/frontend.Dockerfile index 6c0736f5..30f997ad 100644 --- a/docker/deploy/frontend.Dockerfile +++ b/docker/deploy/frontend.Dockerfile @@ -37,7 +37,9 @@ ENV DISABLE_ESLINT_PLUGIN=true ENV NODE_OPTIONS=--max-old-space-size=4096 RUN npm run build -# Production image, copy all the files and run next +# Production image — Next.js standalone output 활용 +# next.config.mjs 의 `output: "standalone"` 이 빌드 시 .next/standalone/ 에 +# server.js + 실제로 사용되는 node_modules 만 자동 포함. node_modules 통째 COPY 불필요. FROM base AS runner WORKDIR /app @@ -47,15 +49,13 @@ ENV NEXT_TELEMETRY_DISABLED 1 RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Copy the Next.js build output +# public 폴더 (standalone 가 자동 포함하지 않음) COPY --from=builder /app/public ./public -# Production 모드에서는 .next 폴더 전체를 복사 -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json - -# node_modules 복사 (production dependencies) -COPY --from=deps --chown=nextjs:nodejs /app/node_modules ./node_modules +# standalone 빌드 결과: server.js + minimal node_modules +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +# static asset (standalone 가 자동 포함하지 않음) +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs @@ -64,6 +64,6 @@ EXPOSE 3000 ENV PORT 3000 ENV HOSTNAME "0.0.0.0" -# Next.js start 명령어 사용 -CMD ["npm", "start"] +# standalone 의 server.js 직접 실행 (npm start 대신) +CMD ["node", "server.js"]