fix: use install.sh script to configure pnpm build dependencies

This commit is contained in:
2026-05-19 17:32:40 +08:00
parent ed4f4767e4
commit 16e6c9e8c4
2 changed files with 13 additions and 6 deletions

View File

@@ -6,12 +6,9 @@ WORKDIR /app
# 允许所有包的 postinstall 脚本Prisma/esbuild 需要) # 允许所有包的 postinstall 脚本Prisma/esbuild 需要)
ENV NPM_CONFIG_IGNORE_SCRIPTS=false ENV NPM_CONFIG_IGNORE_SCRIPTS=false
# 复制依赖文件 # 复制依赖和安装脚本
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml install.sh ./
COPY .npmrc ./ RUN chmod +x install.sh && ./install.sh
# 安装依赖pnpm 会读取 .npmrc 中的 onlyBuiltDependencies
RUN corepack enable && pnpm install --frozen-lockfile --config.onlyBuiltDependencies="@prisma/client,@prisma/engines,esbuild,prisma"
# 复制 Prisma schema 并生成客户端 # 复制 Prisma schema 并生成客户端
COPY prisma/ ./prisma/ COPY prisma/ ./prisma/

10
backend/install.sh Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
set -e
corepack enable
# 设置 pnpm 允许运行 postinstall 脚本的包
pnpm config set onlyBuiltDependencies "@prisma/client @prisma/engines esbuild prisma"
# 安装依赖
pnpm install --frozen-lockfile