fix:优化数据
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
# 分层构建:依赖与代码分离,仅代码变更时只重建 COPY 及以后层
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json ./
|
||||
RUN npm install
|
||||
# 使用国内镜像源,加快安装并减少网络卡死
|
||||
RUN npm config set registry https://registry.npmmirror.com \
|
||||
&& npm config set fetch-retries 5 \
|
||||
&& npm config set fetch-timeout 60000 \
|
||||
&& npm config set fetch-retry-mintimeout 10000
|
||||
|
||||
# 依赖层:只有 package.json / package-lock 变更时才重建
|
||||
COPY package.json ./
|
||||
RUN npm install --prefer-offline --no-audit --progress=false
|
||||
|
||||
# 代码层:业务代码变更只重建此层及后续 build
|
||||
COPY . .
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
Reference in New Issue
Block a user