From 5a2a299bb2894eb27e07cb688ac9eca45339924e Mon Sep 17 00:00:00 2001 From: jun Date: Fri, 16 May 2025 06:24:24 -0400 Subject: [PATCH] =?UTF-8?q?ci(sf-ui):=20=E6=B7=BB=E5=8A=A0=20UI=20?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=20Docker=20=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=92=8C=E6=8E=A8=E9=80=81=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 builder-ui.yaml 工作流,用于在 Gitea 上构建和推送 Docker 镜像 - 在 Makefile 中添加 ui 目标,支持本地构建 - 更新 sf-ui/Dockerfile,使用多阶段构建以减小镜像大小 --- .gitea/workflows/builder-ui.yaml | 26 ++++++++++++++++++++++++++ Makefile | 5 ++++- sf-ui/Dockerfile | 12 ++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/builder-ui.yaml diff --git a/.gitea/workflows/builder-ui.yaml b/.gitea/workflows/builder-ui.yaml new file mode 100644 index 0000000..bdcc513 --- /dev/null +++ b/.gitea/workflows/builder-ui.yaml @@ -0,0 +1,26 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main # 触发分支 + - ca_router + - "releases/*" # 可选通配符 + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: docker/checkout@v4 + + - name: Login to docker.yzj + uses: docker/login-action@v3 + with: + registry: docker.yzj + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: 构建 Docker 镜像 + run: + cd sf-ui && docker build -t docker.yzj/sac/sf-ui -f ./Dockerfile --push . \ No newline at end of file diff --git a/Makefile b/Makefile index c1c6274..b1d6204 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,7 @@ vertx: docker build -t $(DOCKER_REGISTRY)/sac/sf-vertx -f ./sf-vertx/Dockerfile --push . admin: - docker build -t $(DOCKER_REGISTRY)/sac/sf-admin -f ./sf-admin/Dockerfile --push . \ No newline at end of file + docker build -t $(DOCKER_REGISTRY)/sac/sf-admin -f ./sf-admin/Dockerfile --push . + +ui: + cd sf-ui && docker build -t $(DOCKER_REGISTRY)/sac/sf-ui -f ./Dockerfile --push . \ No newline at end of file diff --git a/sf-ui/Dockerfile b/sf-ui/Dockerfile index 0a63bc2..1460c79 100644 --- a/sf-ui/Dockerfile +++ b/sf-ui/Dockerfile @@ -1,6 +1,14 @@ +FROM node:24-alpine AS builder +WORKDIR /app +COPY . . + +RUN npm install --registry=https://registry.npmmirror.com && npm run build:stage + FROM registry.zsmarter.com/public/nginx:1.22.1 -COPY ./sf-ui/dist /app/nginx/html -COPY ./sf-ui/nginx.conf /etc/nginx/nginx.conf + +COPY --from=builder /app/dist /app/nginx/html +COPY --from=builder /app/nginx.conf /etc/nginx/nginx.conf + RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories