From a53304cefa4d84a804608f824d9039796dd19272 Mon Sep 17 00:00:00 2001 From: lezi-fun <177434121+lezi-fun@users.noreply.github.com> Date: Tue, 11 Aug 2026 17:56:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(docker):=20use=20bun=20install=20(npm=20rea?= =?UTF-8?q?ds=20stale=20lockfile=20=E2=86=92=20react=2018)=20+=20.dockerig?= =?UTF-8?q?nore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docker build failed at npm run build: stale package-lock.json pins react@18 while next@16 requires react@19. Switch builder to bun install (bun.lock is current). Add .dockerignore (was shipping 700MB context). --- .dockerignore | 9 +++++++++ dockerfile | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..97a572a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +node_modules +.next +uploads +.git +*.log +.DS_Store +.vercel +.wrangler +.open-next diff --git a/dockerfile b/dockerfile index 25568ce..99f9bd8 100644 --- a/dockerfile +++ b/dockerfile @@ -7,13 +7,16 @@ FROM node:20-alpine AS builder WORKDIR /app ENV DOCKER=1 +# 用 bun 装依赖(bun.lock 最新;npm 会读旧的 package-lock.json → react 18 → 构建失败) +RUN npm i -g bun + # 先装依赖(利用缓存) -COPY package.json package-lock.json* bun.lock* ./ -RUN npm install +COPY package.json bun.lock* package-lock.json* ./ +RUN bun install # 复制源码并构建 COPY . . -RUN npm run build +RUN bun run build # ---- 运行阶段 ---- FROM node:20-alpine AS runner