Skip to content

Commit f56e87b

Browse files
eryajferyajf
authored andcommitted
feat: 添加Docker镜像构建工作流并优化Dockerfile
1 parent b9ade51 commit f56e87b

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

.cnb.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include:
22
- .cnb/workflows/vscode.yml
33
- .cnb/workflows/release.yml
4-
- .cnb/workflows/sync-to-github.yml
4+
- .cnb/workflows/sync-to-github.yml
5+
- .cnb/workflows/build-docker-images.yml
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
main:
2+
push:
3+
- runner:
4+
cpus: 16
5+
services:
6+
- docker
7+
- git-clone-yyds
8+
stages:
9+
- name: 🐋 推送镜像
10+
script: |
11+
docker run -d --name buildkitd \
12+
--security-opt seccomp=unconfined \
13+
--security-opt apparmor=unconfined \
14+
--security-opt systempaths=unconfined \
15+
moby/buildkit:rootless
16+
docker buildx create --use \
17+
--name mybuilder \
18+
--driver remote docker-container://buildkitd
19+
docker buildx build \
20+
-t ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE} \
21+
--platform=linux/arm64,linux/amd64 . --push

Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
FROM node:14.18 AS builder
1+
# 此 Dockerfile 仅用于构建可复制的 dist 内容,并不包含运行环境
2+
# 第一阶段构建不区分平台,可通过指定 --platform=linux/amd64 来声明环境
3+
FROM --platform=linux/amd64 docker.cnb.cool/znb/images/node:18 AS builder
24

3-
RUN mkdir /app
4-
ADD . /app/
55
WORKDIR /app
6+
7+
ADD . .
8+
69
RUN sed -i 's@http://localhost:8888/@/@g' .env.production \
710
&& git config --global url."https://".insteadOf git:// \
811
&& npm install --registry=http://registry.npmmirror.com \
912
&& yarn build:prod
1013

11-
FROM openresty/openresty:1.21.4.1-0-centos7
12-
RUN mkdir /app
14+
FROM docker.cnb.cool/znb/images/alpine
15+
1316
WORKDIR /app
14-
COPY --from=builder /app/default.conf /etc/nginx/conf.d/default.conf
15-
COPY --from=builder /app/dist .
1617

17-
CMD nginx -g "daemon off;"
18+
COPY --from=builder /app/dist/ dist/

0 commit comments

Comments
 (0)