Skip to content

Commit 27d8265

Browse files
authored
Merge pull request #76 from codefuse-ai/workflow_image
Workflow image
2 parents 3f2198d + 7bb5516 commit 27d8265

File tree

6 files changed

+170
-101
lines changed

6 files changed

+170
-101
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docker Image CI Pull
2+
3+
on:
4+
workflow_dispatch: # 允许手动触发工作流
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
architecture: [amd64, arm64]
12+
os: [linux]
13+
service: [runtime:0.1.0, ekgservice:0.1.0, ekgfrontend:0.1.0]
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v1
21+
22+
- name: Set up Buildx
23+
uses: docker/setup-buildx-action@v1
24+
25+
- name: Build the Docker image
26+
run: |
27+
# 登录阿里云镜像仓库
28+
docker login --username=${{ secrets.ALIYUN_USERNAME }} --password=${{ secrets.ALIYUN_PASSWORD }} registry.cn-hangzhou.aliyuncs.com
29+
30+
# 使用Dockerfile构建镜像
31+
docker pull --platform ${{ matrix.os }}/${{ matrix.architecture }} ghcr.io/codefuse-ai/${{ matrix.service }}
32+
docker tag ghcr.io/codefuse-ai/${{ matrix.service }} registry.cn-hangzhou.aliyuncs.com/muagent/${{ matrix.service }}-${{ matrix.architecture }}
33+
docker push registry.cn-hangzhou.aliyuncs.com/muagent/${{ matrix.service }}-${{ matrix.architecture }}

.github/workflows/docker-image.yml

+126-23
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
name: Docker Image CI
2+
23
on:
34
workflow_dispatch: # 允许手动触发工作流
45

56
jobs:
67
build:
7-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-20.04 # 或者指定其他版本
89
strategy:
910
matrix:
10-
architecture: [amd64, arm64]
11+
image:
12+
- name: runtime
13+
context: ./runtime
14+
dockerfile: ./runtime/Dockerfile.no-package
15+
tag: ghcr.io/codefuse-ai/runtime:0.1.0
16+
tag_latest: ghcr.io/codefuse-ai/runtime:latest
17+
- name: ekgfrontend
18+
context: .
19+
dockerfile: ./Dockerfile_frontend
20+
tag: ghcr.io/codefuse-ai/ekgfrontend:0.1.0
21+
tag_latest: ghcr.io/codefuse-ai/ekgfrontend:latest
22+
- name: ekgservice
23+
context: .
24+
dockerfile: ./Dockerfile_gh
25+
tag: ghcr.io/codefuse-ai/ekgservice:0.1.0
26+
tag_latest: ghcr.io/codefuse-ai/ekgservice:latest
1127

1228
steps:
1329
- name: Checkout code
@@ -26,26 +42,113 @@ jobs:
2642
username: ${{ github.actor }} # 使用当前 GitHub 用户名
2743
password: ${{ secrets.CR_TOKEN }} # 使用您刚刚添加的个人访问令牌
2844

29-
- name: Build and push
30-
uses: docker/build-push-action@v2
31-
with:
32-
context: .
33-
file: ./Dockerfile_frontend
34-
push: true
35-
tags: ghcr.io/codefuse-ai/ekgfrontend:0.1.0
45+
- name: Build and push with retry for amd64
46+
run: |
47+
max_retries=5
48+
count=0
49+
success=false
3650
37-
- name: Build and push
38-
uses: docker/build-push-action@v2
39-
with:
40-
context: .
41-
file: ./Dockerfile
42-
push: true
43-
tags: ghcr.io/codefuse-ai/ekgservice:0.1.0
51+
while [[ $count -lt $max_retries ]]; do
52+
echo "Attempt $(($count + 1)) of $max_retries..."
53+
docker build --push \
54+
--platform linux/amd64 \
55+
--tag ${{ matrix.image.tag }}-amd64 \
56+
--tag ${{ matrix.image.tag_latest }}-amd64 \
57+
-f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
58+
59+
count=$(($count + 1))
60+
echo "Build failed, retrying in 5 seconds..."
61+
sleep 15
62+
done
4463
45-
- name: Build and push
46-
uses: docker/build-push-action@v2
47-
with:
48-
context: ./runtime
49-
file: Dockerfile.no-package
50-
push: true
51-
tags: ghcr.io/codefuse-ai/runtime:0.1.0
64+
if [ "$success" = false ]; then
65+
echo "Build failed after $max_retries attempts."
66+
exit 1
67+
fi
68+
69+
- name: docker image for amd64
70+
run: |
71+
df -h
72+
docker images
73+
docker rmi ${{ matrix.image.tag }}-amd64
74+
docker rmi ${{ matrix.image.tag_latest }}-amd64
75+
df -h
76+
docker images
77+
78+
- name: Build and push with retry for arm64
79+
run: |
80+
max_retries=5
81+
count=0
82+
success=false
83+
84+
while [[ $count -lt $max_retries ]]; do
85+
echo "Attempt $(($count + 1)) of $max_retries..."
86+
docker build --push \
87+
--platform linux/arm64 \
88+
--tag ${{ matrix.image.tag }}-arm64 \
89+
--tag ${{ matrix.image.tag_latest }}-arm64 \
90+
-f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
91+
92+
count=$(($count + 1))
93+
echo "Build failed, retrying in 5 seconds..."
94+
sleep 15
95+
done
96+
97+
if [ "$success" = false ]; then
98+
echo "Build failed after $max_retries attempts."
99+
exit 1
100+
fi
101+
102+
- name: docker image for arm64
103+
run: |
104+
df -h
105+
docker images
106+
docker rmi ${{ matrix.image.tag }}-arm64
107+
docker rmi ${{ matrix.image.tag_latest }}-arm64
108+
df -h
109+
docker images
110+
111+
- name: docker manifest
112+
run: |
113+
docker images
114+
115+
docker manifest create ${{ matrix.image.tag }} ${{ matrix.image.tag }}-arm64 ${{ matrix.image.tag }}-amd64
116+
docker manifest create ${{ matrix.image.tag_latest }} ${{ matrix.image.tag_latest }}-arm64 ${{ matrix.image.tag_latest }}-amd64
117+
118+
docker manifest inspect ${{ matrix.image.tag }}
119+
docker manifest inspect ${{ matrix.image.tag_latest }}
120+
121+
docker manifest push ${{ matrix.image.tag }}
122+
docker manifest push ${{ matrix.image.tag_latest }}
123+
124+
- name: Check disk space
125+
run: df -h
126+
127+
# - name: docker image
128+
# run: |
129+
# docker images
130+
# docker pull --platform linux/arm64 python:3.9-slim-bookworm
131+
# docker tag python:3.9-slim-bookworm ghcr.io/lightislost/python:3.9-slim-bookworm-arm64
132+
# docker rmi python:3.9-slim-bookworm
133+
# docker push ghcr.io/lightislost/python:3.9-slim-bookworm-arm64
134+
# docker images
135+
136+
# - name: docker image
137+
# run: |
138+
# docker images
139+
# docker pull --platform linux/amd64 python:3.9-slim-bookworm
140+
# docker tag python:3.9-slim-bookworm ghcr.io/lightislost/python:3.9-slim-bookworm-amd64
141+
# docker rmi python:3.9-slim-bookworm
142+
# docker push ghcr.io/lightislost/python:3.9-slim-bookworm-amd64
143+
# docker images
144+
# docker manifest create ghcr.io/lightislost/python:3.9-slim-bookworm ghcr.io/lightislost/python:3.9-slim-bookworm-arm64 ghcr.io/lightislost/python:3.9-slim-bookworm-amd64
145+
# docker manifest inspect ghcr.io/lightislost/python:3.9-slim-bookworm
146+
147+
# - name: Build and push adm64
148+
# uses: docker/build-push-action@v2
149+
# with:
150+
# context: ${{ matrix.image.context }}
151+
# file: ${{ matrix.image.dockerfile }}
152+
# push: true
153+
# tags: ${{ matrix.image.tag }}-amd64
154+
# platforms: linux/amd64

.github/workflows/test.yaml

-76
This file was deleted.

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9-bookworm
1+
FROM python:3.9-slim-bookworm
22

33
WORKDIR /home/user
44

Dockerfile_frontend

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From node:20.18.0-bookworm
1+
FROM node:20.18.0-bookworm
22

33
WORKDIR /home/user
44

Dockerfile_gh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM python:3.9-slim-bookworm
2+
3+
WORKDIR /home/user
4+
5+
COPY ./requirements.txt /home/user/docker_requirements.txt
6+
7+
RUN pip install -r /home/user/docker_requirements.txt --retries 5 --timeout 120
8+
9+
CMD ["bash"]

0 commit comments

Comments
 (0)