fix(ci): Web构建改用layer缓存替代cache mount,避免node_modules缓存损坏导致构建全挂
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 22s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 51s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 56s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m51s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m4s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 3m33s
AI Code Review / AI Code Review (pull_request) Successful in 4m5s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m28s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 4m49s
Preview Cleanup / Cleanup Preview Environment (pull_request) Failing after 1s
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 22s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 51s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 56s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m51s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m4s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 3m33s
AI Code Review / AI Code Review (pull_request) Successful in 4m5s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m28s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 4m49s
Preview Cleanup / Cleanup Preview Environment (pull_request) Failing after 1s
- 移除node_modules的cache mount,改为写入镜像layer走ACR缓存 - 保留/root/.npm cache mount加速下载(不影响正确性) - 保留.tscache cache mount加速TS增量编译(坏了不影响构建) - layer缓存由ACR跨runner共享,内容完整性由layer哈希保证
This commit is contained in:
@@ -8,10 +8,9 @@ ENV VITE_API_URL=$VITE_API_URL
|
||||
COPY apps/web/package.json apps/web/package-lock.json ./apps/web/
|
||||
WORKDIR /app/apps/web
|
||||
|
||||
# 安装依赖:用BuildKit cache mount缓存npm下载和node_modules
|
||||
# sharing=locked 防止并发构建竞争写缓存
|
||||
# 安装依赖:node_modules写入镜像layer,走ACR缓存保证完整性
|
||||
# /root/.npm 保留cache mount加速下载(不影响构建正确性)
|
||||
RUN --mount=type=cache,target=/root/.npm,sharing=locked \
|
||||
--mount=type=cache,target=/app/apps/web/node_modules,sharing=locked \
|
||||
npm config set registry https://registry.npmmirror.com \
|
||||
&& npm ci
|
||||
|
||||
@@ -19,8 +18,8 @@ RUN --mount=type=cache,target=/root/.npm,sharing=locked \
|
||||
COPY apps/web/ ./
|
||||
|
||||
# 构建:TS增量编译 + Vite构建,tsbuildinfo用cache mount持久化
|
||||
RUN --mount=type=cache,target=/app/apps/web/node_modules,sharing=locked \
|
||||
--mount=type=cache,target=/app/apps/web/.tscache,sharing=locked \
|
||||
# node_modules直接使用镜像中已安装的(layer缓存保证完整性)
|
||||
RUN --mount=type=cache,target=/app/apps/web/.tscache,sharing=locked \
|
||||
mkdir -p .tscache \
|
||||
&& npx tsc --incremental --tsBuildInfoFile .tscache/tsconfig.tsbuildinfo \
|
||||
&& npx vite build
|
||||
|
||||
Reference in New Issue
Block a user