From 38efa891b8188e63b77e5054bf5d360a5feaa9b2 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 24 Feb 2026 00:43:33 -0800 Subject: [PATCH] =?UTF-8?q?fix(snapshot):=20Dockerfile=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20SNAPSHOT=5FSERVICE=5FURL=20build=20ARG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next.js rewrites 在 build 时烘焙到 routes-manifest.json, 运行时环境变量无法覆盖。需要通过 Docker build ARG 在构建时传入。 Co-Authored-By: Claude Opus 4.6 --- frontend/admin-web/Dockerfile | 4 ++++ frontend/mining-admin-web/Dockerfile | 2 ++ 2 files changed, 6 insertions(+) diff --git a/frontend/admin-web/Dockerfile b/frontend/admin-web/Dockerfile index e34318e3..2bdeff6e 100644 --- a/frontend/admin-web/Dockerfile +++ b/frontend/admin-web/Dockerfile @@ -21,6 +21,10 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production +# Next.js rewrite 在 build 时计算, 需要通过 ARG 传入后端服务地址 +ARG SNAPSHOT_SERVICE_URL=http://snapshot-service:3099 +ENV SNAPSHOT_SERVICE_URL=$SNAPSHOT_SERVICE_URL + # 构建应用 RUN npm run build diff --git a/frontend/mining-admin-web/Dockerfile b/frontend/mining-admin-web/Dockerfile index b4171ffe..9f8518ae 100644 --- a/frontend/mining-admin-web/Dockerfile +++ b/frontend/mining-admin-web/Dockerfile @@ -29,9 +29,11 @@ ENV NODE_ENV=production ARG NEXT_PUBLIC_API_URL=http://mining-admin-service:3023 ARG TRADING_SERVICE_URL=http://trading-service:3022 ARG MINING_SERVICE_URL=http://mining-service:3021 +ARG SNAPSHOT_SERVICE_URL=http://snapshot-service-2:3199 ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL ENV TRADING_SERVICE_URL=$TRADING_SERVICE_URL ENV MINING_SERVICE_URL=$MINING_SERVICE_URL +ENV SNAPSHOT_SERVICE_URL=$SNAPSHOT_SERVICE_URL # 确保 public 目录存在(可能为空) RUN mkdir -p public