11name : Docker Image CI
2+
23on :
34 workflow_dispatch : # 允许手动触发工作流
45
56jobs :
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
0 commit comments