refactor: 从 pnpm 切换到 npm

- 去掉 corepack/pnpm,Docker 构建不再卡在下载 pnpm
- Dockerfile 使用 npm ci + npm prune --omit=dev
- 删除 pnpm-lock.yaml,新增 package-lock.json
This commit is contained in:
2026-02-28 23:48:09 +08:00
parent ab623d12da
commit 1188dffc15
4 changed files with 4045 additions and 2611 deletions
+5 -12
View File
@@ -7,21 +7,15 @@ FROM node:22-slim AS builder
# China npm mirror # China npm mirror
RUN npm config set registry https://registry.npmmirror.com RUN npm config set registry https://registry.npmmirror.com
# Enable corepack for pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app WORKDIR /app
# pnpm also uses npm mirror
RUN pnpm config set registry https://registry.npmmirror.com
# Copy package manifests first (layer caching for dependency install) # Copy package manifests first (layer caching for dependency install)
COPY package.json pnpm-lock.yaml ./ COPY package.json package-lock.json ./
# Install all dependencies (including devDependencies for building) # Install all dependencies (including devDependencies for building)
RUN pnpm install --frozen-lockfile RUN npm ci
# Install Chromium for rebrowser-playwright (during build, included in image) # Install Chromium for rebrowser-playwright
RUN npx playwright install chromium RUN npx playwright install chromium
# Copy source code # Copy source code
@@ -29,10 +23,10 @@ COPY tsconfig.json tsup.config.ts ./
COPY src/ src/ COPY src/ src/
# Build the project # Build the project
RUN pnpm build RUN npm run build
# Remove devDependencies to slim down node_modules for production # Remove devDependencies to slim down node_modules for production
RUN pnpm prune --prod RUN npm prune --omit=dev
# ============================================================================= # =============================================================================
# Stage 2: Production # Stage 2: Production
@@ -41,7 +35,6 @@ RUN pnpm prune --prod
FROM node:22-slim FROM node:22-slim
# Install Chromium dependencies required by Playwright/rebrowser-playwright # Install Chromium dependencies required by Playwright/rebrowser-playwright
# These are the shared libraries Chromium needs to run in headless mode.
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
libnss3 \ libnss3 \
libnspr4 \ libnspr4 \
+4040
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -24,7 +24,6 @@
], ],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"packageManager": "pnpm@10.25.0",
"engines": { "engines": {
"node": ">=22.0.0" "node": ">=22.0.0"
}, },
@@ -43,10 +42,5 @@
"tsup": "^8.0.0", "tsup": "^8.0.0",
"typescript": "^5.7.0", "typescript": "^5.7.0",
"vitest": "^3.0.0" "vitest": "^3.0.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
} }
} }
-2593
View File
File diff suppressed because it is too large Load Diff