From 4b9b22a2fe73cd216151a46f690a7c9ed7d1c500 Mon Sep 17 00:00:00 2001 From: chpark Date: Wed, 13 May 2026 16:06:04 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20next.js=20standalone=20?= =?UTF-8?q?=EB=AA=A8=EB=93=9C=EC=99=80=20=EC=8B=A4=ED=96=89=20=EB=AA=85?= =?UTF-8?q?=EB=A0=B9=20=EC=A0=95=ED=95=A9=20=E2=80=94=20next=20start=20?= =?UTF-8?q?=E2=86=92=20node=20server.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next.js 15 부터 output: "standalone" 설정 시 next start 로 실행하면 정적 자원(_next/static)이 404, API rewrite도 동작 안 함. .next/standalone/server.js 직접 실행하도록 Dockerfile 변경. static/public 디렉토리는 standalone 트리에 같이 복사해야 함. Co-Authored-By: Claude Opus 4.7 (1M context) --- docker/edge/Dockerfile.frontend.prod | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/edge/Dockerfile.frontend.prod b/docker/edge/Dockerfile.frontend.prod index d102fe75..fc073352 100644 --- a/docker/edge/Dockerfile.frontend.prod +++ b/docker/edge/Dockerfile.frontend.prod @@ -1,4 +1,5 @@ -# Pipeline Frontend — 엣지 배포용 프로덕션 이미지 (next build + next start) +# Pipeline Frontend — 엣지 배포용 프로덕션 이미지 (next build standalone) +# next.config 의 output: "standalone" 산출물을 그대로 실행. node .next/standalone/server.js FROM node:20-bookworm-slim AS builder @@ -9,7 +10,7 @@ RUN npm ci --prefer-offline --no-audit COPY . . -# 프로덕션 빌드 +# 프로덕션 빌드 (standalone) ENV NEXT_TELEMETRY_DISABLED=1 RUN npm run build @@ -21,16 +22,15 @@ WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 ENV PORT=3000 +ENV HOSTNAME=0.0.0.0 -COPY package*.json ./ -RUN npm ci --omit=dev --prefer-offline --no-audit \ - && npm cache clean --force +# standalone 산출물: server.js + minimal node_modules (자체 포함) +COPY --from=builder /app/.next/standalone ./ -# 빌드 결과물 -COPY --from=builder /app/.next ./.next +# standalone 은 static/public 을 자기 트리 밖에서 찾으므로 같은 자리에 복사 +COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/public ./public -COPY --from=builder /app/next.config.* ./ EXPOSE 3000 -CMD ["npx", "next", "start", "-p", "3000"] +CMD ["node", "server.js"]