From 1d19fc86ee2036885f19e6dbaed0251b7f87c0fa Mon Sep 17 00:00:00 2001 From: erio Date: Sat, 7 Mar 2026 04:31:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Dockerfile=20=E6=9E=84=E5=BB=BA=E6=97=B6?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=20dummy=20=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E9=81=BF=E5=85=8D=E9=A2=84=E6=B8=B2=E6=9F=93=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 51d19f8..ffe41cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,13 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . RUN pnpm prisma generate -RUN pnpm build +# 构建时注入 dummy 环境变量,避免 Next.js 预渲染 API 路由时 getEnv() 报错 +RUN DATABASE_URL="postgresql://x:x@localhost/x" \ + SUB2API_BASE_URL="https://localhost" \ + SUB2API_ADMIN_API_KEY="build-dummy" \ + ADMIN_TOKEN="build-dummy" \ + NEXT_PUBLIC_APP_URL="https://localhost" \ + pnpm build FROM node:22-alpine AS runner WORKDIR /app