From 6d7ae35664e0625c49aa47af3c5609bfc7aa8609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=EF=BC=9A?= =?UTF-8?q?=E5=82=A8=E5=87=A1?= <77527113+chufan443@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:38:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(GitHub=20Actions):=20=E4=BF=AE=E5=A4=8D`CI`?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF`docker`=E6=9E=84=E5=BB=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20(#110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(GitHub Actions): 修复`CI`流水线`docker`构建异常 * chore: update * chore: update * chore: update --------- Co-authored-by: chufan --- .github/workflows/CI.yml | 33 ++++++++++++++++++++++++--------- Dockerfile | 11 +++++++---- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c8fecb6b..06f05084 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,7 +27,7 @@ jobs: Base-Build: name: 基础编译构建 runs-on: ubuntu-latest - # # 主库且拉取PR时触发 + # 主库且拉取PR时触发 if: github.repository == '142vip/408CSFamily' && github.event_name == 'pull_request' permissions: actions: read @@ -47,7 +47,7 @@ jobs: with: version: 9.6.0 - # # 安装Node环境 + # 安装Node环境 - name: Install Node.js uses: actions/setup-node@v3 with: @@ -55,7 +55,7 @@ jobs: # # 缓存 cache: pnpm - # # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建 + # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建 - name: Install Dependencies run: | ./scripts/ci @@ -75,7 +75,7 @@ jobs: Build-Docker-Image: name: 构建Docker镜像 runs-on: ubuntu-latest - # # 主库且tag更新时执行 + # 主库且tag更新时执行 if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):') permissions: actions: read @@ -104,16 +104,31 @@ jobs: --password=${{ secrets.DOCKER_PASSWORD }} \ ${{env.REGISTRY}} + # 安装PNPM + - name: PNPM Install + uses: pnpm/action-setup@v4 + with: + version: 9.6.0 + + # 安装Node环境 + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.16.0 + # # 缓存 + cache: pnpm + + # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建 - name: Install Dependencies run: | ./scripts/ci - # # 构建,支持domain - - name: Build To Dist - run: | - pnpm build + # # 构建,支持domain + # - name: Build To Dist + # run: | + # pnpm build - # # 快速构建并推送 + # 快速构建并推送 - name: Push Docker Image run: | ./scripts/bundle diff --git a/Dockerfile b/Dockerfile index ebe94a41..365df4ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # # - 功能: 408CSFamily镜像构建 -# - 用法: docker build -f Dockerfile --build-arg APP_VERSION=0.0.1 --build-arg CONTAINER_BUILD=true -t 408CSFamily-0.0.1 . +# - 用法: docker build -f Dockerfile --build-arg APP_VERSION=0.0.1 -t 408CSFamily-0.0.1 . # - 参数: # APP_VERSION: 版本 # CONTAINER_BUILD: 采用容器构建 @@ -20,11 +20,14 @@ COPY . . RUN echo $CONTAINER_BUILD; ## 基于容器自动构建 -RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "$CONTAINER_BUILD" = "true" ]; then \ - sh ./scripts/ci && pnpm build; \ +RUN --mount=type=cache,id=pnpm,target=/pnpm/store sh ./scripts/ci && if [ "$NEED_PROXY" = "false" ]; \ + then \ + pnpm build; \ + else \ + pnpm build:proxy; \ fi; -FROM registry.cn-hangzhou.aliyuncs.com/142vip/nginx:1.23.0-alpine +FROM registry.cn-hangzhou.aliyuncs.com/142vip/nginx:1.27.0-alpine ARG APP_NAME ARG APP_VERSION