fix(docker): 修复 Dockerfile npm 构建错误并优化测试配置

- 修复 Dockerfile 使用 pnpm 替代 npm ci(适配 pnpm 迁移)
- 为 docker-compose-test.yml 添加自动构建配置
- 更新测试配置文档说明一键构建命令

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Jiahao Luo
2026-01-05 11:10:31 +08:00
parent a11a0f289c
commit 0f79c3cc0e
2 changed files with 13 additions and 6 deletions

View File

@@ -19,13 +19,16 @@ FROM ${NODE_IMAGE} AS frontend-builder
WORKDIR /app/frontend WORKDIR /app/frontend
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install dependencies first (better caching) # Install dependencies first (better caching)
COPY frontend/package*.json ./ COPY frontend/package.json frontend/pnpm-lock.yaml ./
RUN npm ci RUN pnpm install --frozen-lockfile
# Copy frontend source and build # Copy frontend source and build
COPY frontend/ ./ COPY frontend/ ./
RUN npm run build RUN pnpm run build
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Stage 2: Backend Builder # Stage 2: Backend Builder

View File

@@ -1,12 +1,13 @@
# ============================================================================= # =============================================================================
# Sub2API Docker Compose Configuration # Sub2API Docker Compose Test Configuration (Local Build)
# ============================================================================= # =============================================================================
# Quick Start: # Quick Start:
# 1. Copy .env.example to .env and configure # 1. Copy .env.example to .env and configure
# 2. docker-compose up -d # 2. docker-compose -f docker-compose-test.yml up -d --build
# 3. Check logs: docker-compose logs -f sub2api # 3. Check logs: docker-compose -f docker-compose-test.yml logs -f sub2api
# 4. Access: http://localhost:8080 # 4. Access: http://localhost:8080
# #
# This configuration builds the image from source (Dockerfile in project root).
# All configuration is done via environment variables. # All configuration is done via environment variables.
# No Setup Wizard needed - the system auto-initializes on first run. # No Setup Wizard needed - the system auto-initializes on first run.
# ============================================================================= # =============================================================================
@@ -17,6 +18,9 @@ services:
# =========================================================================== # ===========================================================================
sub2api: sub2api:
image: sub2api:latest image: sub2api:latest
build:
context: ..
dockerfile: Dockerfile
container_name: sub2api container_name: sub2api
restart: unless-stopped restart: unless-stopped
ulimits: ulimits: