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