fix(ci): explicit prisma generate + ignore-scripts in Docker build
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Root cause: pnpm 10+ skips lifecycle scripts in root/CI environments by default, so the project's postinstall (prisma generate) never ran. The runner stage then failed to COPY node_modules/.prisma because builder never produced it. Fix: install with --ignore-scripts, then call `pnpm exec prisma generate` explicitly in both deps and builder stages, with ls assertions to surface any future regression early. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6155638549
commit
d2b8c0afdc
14
Dockerfile
14
Dockerfile
@ -1,5 +1,5 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# ───────────── 1. deps:安装依赖(含 prisma generate via postinstall) ─────────────
|
||||
# ───────────── 1. deps:安装依赖 + 显式生成 Prisma Client ─────────────
|
||||
FROM node:22-alpine AS deps
|
||||
RUN apk add --no-cache libc6-compat openssl
|
||||
WORKDIR /app
|
||||
@ -9,7 +9,12 @@ RUN corepack enable && corepack prepare pnpm@latest --activate \
|
||||
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY prisma ./prisma
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# pnpm 10+ 在 root/CI 环境默认不跑 lifecycle scripts,因此显式调用 prisma generate
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts \
|
||||
&& pnpm exec prisma generate \
|
||||
&& ls -la /app/node_modules/.prisma/client/ \
|
||||
&& ls -la /app/node_modules/@prisma/client/
|
||||
|
||||
# ───────────── 2. builder:Next.js 构建(standalone 产物) ─────────────
|
||||
FROM node:22-alpine AS builder
|
||||
@ -22,7 +27,10 @@ COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN pnpm build
|
||||
# 再次保险生成(COPY . . 会覆盖 prisma/ schema 的最新版本),然后构建
|
||||
RUN pnpm exec prisma generate \
|
||||
&& pnpm exec next build \
|
||||
&& ls -la /app/node_modules/.prisma/client/
|
||||
|
||||
# ───────────── 3. runner:最小运行时镜像 ─────────────
|
||||
FROM node:22-alpine AS runner
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user