修改docker脚本
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Sync to CNB / sync (push) Has been cancelled
Delete old workflow runs / del_runs (push) Has been cancelled
Upstream Sync / Sync latest commits from upstream repo (push) Has been cancelled

This commit is contained in:
2026-02-02 17:27:18 +08:00
parent 3d175d75af
commit 964451c383
3 changed files with 43 additions and 4 deletions

View File

@@ -1,11 +1,20 @@
FROM node:20-alpine AS base
# 默认使用本地镜像 local-node:20-alpine可先执行: docker tag node:20-alpine local-node:20-alpine
# 也可通过 --build-arg NODE_IMAGE=xxx 指定其他镜像
ARG NODE_IMAGE=node:20-alpine
FROM ${NODE_IMAGE} AS base
FROM base AS deps
# 国内构建若卡在 npm ci可传 --build-arg NPM_REGISTRY=https://registry.npmmirror.com
ARG NPM_REGISTRY=https://registry.npmjs.org/
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
# 提高超时与重试,避免内网/跨平台构建时 npm 拉包 EIDLETIMEOUT
RUN npm config set fetch-timeout 300000 && npm config set fetch-retries 5 && npm ci
RUN npm config set registry "$NPM_REGISTRY" \
&& npm config set fetch-timeout 300000 \
&& npm config set fetch-retries 5
# 使用 BuildKit 缓存 npm 目录,二次构建更快
RUN --mount=type=cache,target=/root/.npm \
npm ci
# Rebuild the source code only when needed
FROM base AS builder