File tree Expand file tree Collapse file tree 5 files changed +55
-22
lines changed Expand file tree Collapse file tree 5 files changed +55
-22
lines changed Original file line number Diff line number Diff line change 1+ FROM node:18.20-alpine as Builder
2+
3+ WORKDIR /space
4+
5+ COPY . .
6+
7+ RUN apk add git \
8+ && git config --global url."https://" .insteadOf git:// \
9+ && npm install --registry=http://registry.npmmirror.com
10+
11+ ENV NODE_PATH=/space/node_modules
Original file line number Diff line number Diff line change 66 - docker
77 - git-clone-yyds
88 stages :
9+ - name : 构建缓存镜像
10+ type : docker:cache
11+ options :
12+ dockerfile : cache.dockerfile
13+ by :
14+ - package.json
15+ - package-lock.json
16+ versionBy :
17+ - package.json
18+ exports :
19+ name : DOCKER_CACHE_IMAGE_NAME
20+ - name : 直接使用缓存镜像环境安装依赖并编译
21+ image : $DOCKER_CACHE_IMAGE_NAME
22+ script : |
23+ ln -snf $NODE_PATH node_modules
24+ time npm install
25+ sed -i 's@http://localhost:8888/@/@g' .env.production
26+ time yarn build:prod
927 - name : 🐋 推送镜像
1028 script : |
1129 docker run -d --name buildkitd \
Original file line number Diff line number Diff line change 66 - docker
77 - git-clone-yyds
88 stages :
9- - name : 📦 构建制品
10- image : docker.cnb.cool/znb/images/debian:all
9+ - name : 构建缓存镜像
10+ type : docker:cache
11+ options :
12+ dockerfile : cache.dockerfile
13+ by :
14+ - package.json
15+ - package-lock.json
16+ versionBy :
17+ - package.json
18+ exports :
19+ name : DOCKER_CACHE_IMAGE_NAME
20+ - name : 直接使用缓存镜像环境安装依赖并编译
21+ image : $DOCKER_CACHE_IMAGE_NAME
1122 script : |
23+ ln -snf $NODE_PATH node_modules
24+ time npm install
1225 sed -i 's@http://localhost:8888/@/@g' .env.production
13- npm install --registry=http://registry.npmmirror.com
14- yarn build:prod
26+ time yarn build:prod
27+ - name : 📦 构建制品
28+ image : docker.cnb.cool/znb/images/debian
29+ script : |
1530 zip -q -r dist.zip dist
1631 openssl md5 dist.zip > dist.zip.md5
1732 - name : 🐋 推送制品
Original file line number Diff line number Diff line change @@ -12,14 +12,16 @@ jobs:
1212 runs-on : ubuntu-latest
1313 steps :
1414 - name : Checkout 🛎️
15- uses : actions/checkout@v3
15+ uses : actions/checkout@v5
1616 - name : Inject slug/short variables
17- uses : rlespinasse/github-slug-action@v4
17+ uses : rlespinasse/github-slug-action@v5
1818
1919 - name : build project ⚗️
20- uses : actions/setup-node@v3
20+ uses : actions/setup-node@v5
2121 with :
2222 node-version : 14
23+ cache : ' npm'
24+ cache-dependency-path : " package-lock.json"
2325
2426 - run : |
2527 sed -i 's@http://localhost:8888/@/@g' .env.production
3234 openssl md5 dist.zip > dist.zip.md5
3335
3436 - name : Upload release package
35- uses : softprops/action-gh-release@v1
37+ uses : softprops/action-gh-release@v2
3638 with :
3739 files : |
3840 dist.zip
Original file line number Diff line number Diff line change 1- # 此 Dockerfile 仅用于构建可复制的 dist 内容,并不包含运行环境
2- # 第一阶段构建不区分平台,可通过指定 --platform=linux/amd64 来声明环境
3- FROM --platform=linux/amd64 docker.cnb.cool/znb/images/node:18 AS builder
4-
5- WORKDIR /app
6-
7- ADD . .
8-
9- RUN sed -i 's@http://localhost:8888/@/@g' .env.production \
10- && git config --global url."https://" .insteadOf git:// \
11- && npm install --registry=http://registry.npmmirror.com \
12- && yarn build:prod
13-
141FROM docker.cnb.cool/znb/images/alpine
152
163WORKDIR /app
174
18- COPY --from=builder /app/ dist/ dist/
5+ COPY dist ./dist
You can’t perform that action at this time.
0 commit comments