File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5252 uses : docker/build-push-action@v6
5353 with :
5454 context : .
55+ pull : true
5556 push : ${{ github.event_name != 'pull_request' }}
5657 tags : ${{ steps.meta.outputs.tags }}
5758 labels : ${{ steps.meta.outputs.labels }}
5859 cache-from : type=gha
5960 cache-to : type=gha,mode=max
61+ build-args : |
62+ NPM_REGISTRY=https://registry.npmjs.org
Original file line number Diff line number Diff line change 1+ # 全局参数:镜像源(CI 时通过 --build-arg NPM_REGISTRY=... 覆盖)
2+ ARG NPM_REGISTRY=https://registry.npmjs.org/
3+
14# 阶段1:基础镜像准备
2- FROM node:18 -alpine AS base
5+ FROM node:20 -alpine AS base
36
47# 设置工作目录
58WORKDIR /app
69
7- # 配置国内镜像源
8- RUN npm config set registry https://registry.npmmirror.com/
10+ # 配置镜像源
11+ RUN npm config set registry ${NPM_REGISTRY}
912
1013# 安装必要的系统依赖(例如 CA 证书)
11- RUN apk add --no-cache ca-certificates
14+ RUN apk update && apk add --no-cache ca-certificates && update- ca-certificates
1215
1316# 阶段2:构建应用程序
1417FROM base AS builder
@@ -19,6 +22,7 @@ WORKDIR /app
1922COPY package.json yarn.lock ./
2023
2124# 安装所有依赖,包括开发依赖
25+ RUN yarn config set registry ${NPM_REGISTRY}
2226RUN yarn install
2327
2428# 复制项目源代码
@@ -40,7 +44,7 @@ RUN yarn install --production --ignore-scripts --prefer-offline
4044RUN yarn cache clean --all
4145
4246# 阶段3:构建最终的生产镜像
43- FROM node:18 -alpine
47+ FROM node:20 -alpine
4448
4549# 设置工作目录
4650WORKDIR /app
You can’t perform that action at this time.
0 commit comments