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:
+5
-12
@@ -7,21 +7,15 @@ FROM node:22-slim AS builder
|
||||
# China npm mirror
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
# Enable corepack for pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
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.json pnpm-lock.yaml ./
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# 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
|
||||
|
||||
# Copy source code
|
||||
@@ -29,10 +23,10 @@ COPY tsconfig.json tsup.config.ts ./
|
||||
COPY src/ src/
|
||||
|
||||
# Build the project
|
||||
RUN pnpm build
|
||||
RUN npm run build
|
||||
|
||||
# Remove devDependencies to slim down node_modules for production
|
||||
RUN pnpm prune --prod
|
||||
RUN npm prune --omit=dev
|
||||
|
||||
# =============================================================================
|
||||
# Stage 2: Production
|
||||
@@ -41,7 +35,6 @@ RUN pnpm prune --prod
|
||||
FROM node:22-slim
|
||||
|
||||
# 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 \
|
||||
libnss3 \
|
||||
libnspr4 \
|
||||
|
||||
Reference in New Issue
Block a user