fix: checkout 后显式 git fetch 切换触发分支,避免始终部署 main 代码;Dockerfile 添加 BuildKit cache mount 加速构建
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user