From 5d4599642a268983ccd56a3b587cc133fbd56dfe Mon Sep 17 00:00:00 2001 From: gahusb Date: Sat, 6 Jun 2026 14:50:08 +0900 Subject: [PATCH] =?UTF-8?q?feat(deploy):=20Next=20standalone=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=20+=20Dockerfile=20(NAS=20self-host=20Phase=203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - next.config: output 'standalone' + outputFileTracingRoot(workspace 중첩 방지) - Dockerfile(멀티스테이지, NEXT_PUBLIC_* build-arg) + .dockerignore - maxDuration은 Vercel 운영 보호 위해 유지(self-host에선 무시됨) - 로컬 빌드 검증: .next/standalone/server.js 루트 생성 확인 Co-Authored-By: Claude Opus 4.8 (1M context) --- .dockerignore | 10 ++++++++++ Dockerfile | 28 ++++++++++++++++++++++++++++ next.config.ts | 4 ++++ 3 files changed, 42 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..714cbee --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +.next +.git +.env* +docs +supabase +*.md +.vercel +.DS_Store +npm-debug.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a609f97 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# 쟁승메이드 Next.js — NAS self-host용 standalone 컨테이너 +# 빌드는 로컬에서(NAS Celeron 빌드 금지). NEXT_PUBLIC_* 는 빌드타임 인라인이라 build-arg로 주입. +FROM node:20-alpine AS deps +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci + +FROM node:20-alpine AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +ARG NEXT_PUBLIC_SUPABASE_URL +ARG NEXT_PUBLIC_SUPABASE_ANON_KEY +ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL +ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY +ENV NEXT_TELEMETRY_DISABLED=1 +RUN npm run build + +FROM node:20-alpine AS runner +WORKDIR /app +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +# next.config output:'standalone' 산출물 +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/public ./public +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/next.config.ts b/next.config.ts index 1163232..b7e59ef 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,10 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { + // self-host(NAS) 배포용 standalone 출력. Vercel은 이 설정을 무시하므로 양쪽 호환. + output: 'standalone', + // workspace/ 하위 프로젝트라 Next가 상위를 추적 루트로 오인 → standalone 중첩 방지 위해 고정 + outputFileTracingRoot: process.cwd(), async headers() { return [ {