Skip to content

Commit

Permalink
fix(GitHub Actions): 修复CI流水线docker构建异常 (#110)
Browse files Browse the repository at this point in the history
* fix(GitHub Actions): 修复`CI`流水线`docker`构建异常

* chore: update

* chore: update

* chore: update

---------

Co-authored-by: chufan <[email protected]>
  • Loading branch information
微信公众号:储凡 and mmdapl authored Oct 5, 2024
1 parent cd00b03 commit 6d7ae35
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
33 changes: 24 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,15 +47,15 @@ jobs:
with:
version: 9.6.0

# # 安装Node环境
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20.16.0
# # 缓存
cache: pnpm

# # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
# 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
Expand All @@ -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
Expand Down Expand Up @@ -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
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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: 采用容器构建
Expand All @@ -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
Expand Down

0 comments on commit 6d7ae35

Please sign in to comment.