fix(frontend): next.js standalone 모드와 실행 명령 정합 — next start → node server.js
Build and Push Images / build-and-push (push) Has been cancelled
Build and Push Images / build-and-push (push) Has been cancelled
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user