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:24-alpine AS base
6+
7+ ARG NPM_REGISTRY
38
49# 设置工作目录
510WORKDIR /app
611
7- # 配置国内镜像源
8- RUN npm config set registry https://registry.npmmirror.com/
12+ # 配置镜像源
13+ RUN npm config set registry ${NPM_REGISTRY}
914
1015# 安装必要的系统依赖(例如 CA 证书)
11- RUN apk add --no-cache ca-certificates
16+ RUN apk update && apk add --no-cache ca-certificates && update- ca-certificates
1217
1318# 阶段2:构建应用程序
1419FROM base AS builder
1520
21+ ARG NPM_REGISTRY
22+
1623WORKDIR /app
1724
1825# 复制依赖文件
1926COPY package.json yarn.lock ./
2027
2128# 安装所有依赖,包括开发依赖
29+ RUN yarn config set registry ${NPM_REGISTRY}
2230RUN yarn install
2331
2432# 复制项目源代码
@@ -40,7 +48,7 @@ RUN yarn install --production --ignore-scripts --prefer-offline
4048RUN yarn cache clean --all
4149
4250# 阶段3:构建最终的生产镜像
43- FROM node:18 -alpine
51+ FROM node:24 -alpine
4452
4553# 设置工作目录
4654WORKDIR /app
You can’t perform that action at this time.
0 commit comments