fix: checkout 后显式 git fetch 切换触发分支,避免始终部署 main 代码;Dockerfile 添加 BuildKit cache mount 加速构建

This commit is contained in:
hhs
2026-06-20 17:43:32 +08:00
parent 6bb4773e07
commit 12e2d24f37
3 changed files with 28 additions and 7 deletions

View File

@@ -8,11 +8,17 @@ RUN npm config set registry https://registry.npmmirror.com
# 先复制依赖清单,利用 Docker 缓存层
COPY package.json package-lock.json ./
RUN npm ci
# 复制源码并构建
# --mount=type=cache 复用 npm 缓存,依赖不变时跳过下载
# --no-audit 跳过安全审计,提速明显
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit
# 复制源码并构建Vite 构建缓存也复用)
COPY . .
RUN npm run build
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/app/node_modules/.vite \
npm run build
# ---- 运行阶段 ----
FROM nginx:stable-alpine