diff --git a/infra/docker/web.Dockerfile b/infra/docker/web.Dockerfile index f800ed684..12fe02505 100755 --- a/infra/docker/web.Dockerfile +++ b/infra/docker/web.Dockerfile @@ -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