From f10dfb817262bb8cd42ea2151b3a441e8e504d96 Mon Sep 17 00:00:00 2001 From: yangsong13 Date: Thu, 21 Nov 2024 20:06:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=85=E5=AF=B9NEXT=5FBUILD=5FSTANDA?= =?UTF-8?q?LONE=3Dtrue=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 1 + Dockerfile | 6 +++++- next.config.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index eb29e18c..58d0b56f 100644 --- a/.env.example +++ b/.env.example @@ -173,3 +173,4 @@ # ENABLE_CACHE= # VERCEL_ENV= # NEXT_PUBLIC_VERSION= +# NEXT_BUILD_STANDALONE= diff --git a/Dockerfile b/Dockerfile index d08b984b..01185002 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,16 +14,20 @@ RUN yarn install --frozen-lockfile # 2. Rebuild the source code only when needed FROM base AS builder ARG NOTION_PAGE_ID +ENV NEXT_BUILD_STANDALONE=true + WORKDIR /app + COPY --from=deps /app/node_modules ./node_modules COPY . . RUN yarn build # 3. Production image, copy all the files and run next FROM base AS runner +ENV NODE_ENV=production + WORKDIR /app -ENV NODE_ENV=production COPY --from=builder /app/public ./public diff --git a/next.config.js b/next.config.js index 972e85fb..658001ed 100644 --- a/next.config.js +++ b/next.config.js @@ -84,7 +84,7 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true }, - output: process.env.EXPORT ? 'export' : 'standalone', + output: process.env.EXPORT ? 'export' : process.env.NEXT_BUILD_STANDALONE === 'true' ? 'standalone' : undefined, staticPageGenerationTimeout: 120, // 多语言, 在export时禁用 i18n: process.env.EXPORT