-
Notifications
You must be signed in to change notification settings - Fork 66
154 lines (130 loc) · 5.34 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Docker Image CI
on:
workflow_dispatch: # 允许手动触发工作流
jobs:
build:
runs-on: ubuntu-20.04 # 或者指定其他版本
strategy:
matrix:
image:
- name: runtime
context: ./runtime
dockerfile: ./runtime/Dockerfile.no-package
tag: ghcr.io/codefuse-ai/runtime:0.1.0
tag_latest: ghcr.io/codefuse-ai/runtime:latest
- name: ekgfrontend
context: .
dockerfile: ./Dockerfile_frontend
tag: ghcr.io/codefuse-ai/ekgfrontend:0.1.0
tag_latest: ghcr.io/codefuse-ai/ekgfrontend:latest
- name: ekgservice
context: .
dockerfile: ./Dockerfile_gh
tag: ghcr.io/codefuse-ai/muagent:0.1.0
tag_latest: ghcr.io/codefuse-ai/muagent:latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }} # 使用当前 GitHub 用户名
password: ${{ secrets.CR_TOKEN }} # 使用您刚刚添加的个人访问令牌
- name: Build and push with retry for amd64
run: |
max_retries=5
count=0
success=false
while [[ $count -lt $max_retries ]]; do
echo "Attempt $(($count + 1)) of $max_retries..."
docker build --push \
--platform linux/amd64 \
--tag ${{ matrix.image.tag }}-amd64 \
--tag ${{ matrix.image.tag_latest }}-amd64 \
-f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
count=$(($count + 1))
echo "Build failed, retrying in 5 seconds..."
sleep 15
done
if [ "$success" = false ]; then
echo "Build failed after $max_retries attempts."
exit 1
fi
- name: docker image for amd64
run: |
df -h
docker images
docker rmi ${{ matrix.image.tag }}-amd64
docker rmi ${{ matrix.image.tag_latest }}-amd64
df -h
docker images
- name: Build and push with retry for arm64
run: |
max_retries=5
count=0
success=false
while [[ $count -lt $max_retries ]]; do
echo "Attempt $(($count + 1)) of $max_retries..."
docker build --push \
--platform linux/arm64 \
--tag ${{ matrix.image.tag }}-arm64 \
--tag ${{ matrix.image.tag_latest }}-arm64 \
-f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
count=$(($count + 1))
echo "Build failed, retrying in 5 seconds..."
sleep 15
done
if [ "$success" = false ]; then
echo "Build failed after $max_retries attempts."
exit 1
fi
- name: docker image for arm64
run: |
df -h
docker images
docker rmi ${{ matrix.image.tag }}-arm64
docker rmi ${{ matrix.image.tag_latest }}-arm64
df -h
docker images
- name: docker manifest
run: |
docker images
docker manifest create ${{ matrix.image.tag }} ${{ matrix.image.tag }}-arm64 ${{ matrix.image.tag }}-amd64
docker manifest create ${{ matrix.image.tag_latest }} ${{ matrix.image.tag_latest }}-arm64 ${{ matrix.image.tag_latest }}-amd64
docker manifest inspect ${{ matrix.image.tag }}
docker manifest inspect ${{ matrix.image.tag_latest }}
docker manifest push ${{ matrix.image.tag }}
docker manifest push ${{ matrix.image.tag_latest }}
- name: Check disk space
run: df -h
# - name: docker image
# run: |
# docker images
# docker pull --platform linux/arm64 python:3.9-slim-bookworm
# docker tag python:3.9-slim-bookworm ghcr.io/lightislost/python:3.9-slim-bookworm-arm64
# docker rmi python:3.9-slim-bookworm
# docker push ghcr.io/lightislost/python:3.9-slim-bookworm-arm64
# docker images
# - name: docker image
# run: |
# docker images
# docker pull --platform linux/amd64 python:3.9-slim-bookworm
# docker tag python:3.9-slim-bookworm ghcr.io/lightislost/python:3.9-slim-bookworm-amd64
# docker rmi python:3.9-slim-bookworm
# docker push ghcr.io/lightislost/python:3.9-slim-bookworm-amd64
# docker images
# 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
# docker manifest inspect ghcr.io/lightislost/python:3.9-slim-bookworm
# - name: Build and push adm64
# uses: docker/build-push-action@v2
# with:
# context: ${{ matrix.image.context }}
# file: ${{ matrix.image.dockerfile }}
# push: true
# tags: ${{ matrix.image.tag }}-amd64
# platforms: linux/amd64