1
- name : Docker Image CI Test
1
+ name : Docker Image CI
2
2
3
3
on :
4
4
workflow_dispatch : # 允许手动触发工作流
@@ -62,31 +62,76 @@ jobs:
62
62
# 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
63
63
# docker manifest inspect ghcr.io/lightislost/python:3.9-slim-bookworm
64
64
65
- - name : Build and push adm64
66
- uses : docker/build-push-action@v2
67
- with :
68
- context : ${{ matrix.image.context }}
69
- file : ${{ matrix.image.dockerfile }}
70
- push : true
71
- tags : ${{ matrix.image.tag }}-amd64
72
- platforms : linux/amd64
65
+ # - name: Build and push adm64
66
+ # uses: docker/build-push-action@v2
67
+ # with:
68
+ # context: ${{ matrix.image.context }}
69
+ # file: ${{ matrix.image.dockerfile }}
70
+ # push: true
71
+ # tags: ${{ matrix.image.tag }}-amd64
72
+ # platforms: linux/amd64
73
+
74
+ - name : Build and push with retry for amd64
75
+ run : |
76
+ max_retries=3
77
+ count=0
78
+ success=false
73
79
80
+ while [[ $count -lt $max_retries ]]; do
81
+ echo "Attempt $(($count + 1)) of $max_retries..."
82
+ docker buildx build --push \
83
+ --platform linux/amd64 \
84
+ --tag ${{ matrix.image.tag }}-amd64 \
85
+ -f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
86
+
87
+ count=$(($count + 1))
88
+ echo "Build failed, retrying in 5 seconds..."
89
+ sleep 5
90
+ done
91
+
92
+ if [ "$success" = false ]; then
93
+ echo "Build failed after $max_retries attempts."
94
+ exit 1
95
+ fi
96
+ 3
74
97
- name : docker image
75
98
run : |
76
99
docker images
77
100
docker rmi ${{ matrix.image.tag }}-amd64
78
101
docker images
79
102
103
+ # - name: Build and push amr64
104
+ # uses: docker/build-push-action@v2
105
+ # with:
106
+ # context: ${{ matrix.image.context }}
107
+ # file: ${{ matrix.image.dockerfile }}
108
+ # push: true
109
+ # tags: ${{ matrix.image.tag }}-arm64
110
+ # platforms: linux/arm64
111
+
112
+ - name : Build and push with retry for arm64
113
+ run : |
114
+ max_retries=3
115
+ count=0
116
+ success=false
117
+
118
+ while [[ $count -lt $max_retries ]]; do
119
+ echo "Attempt $(($count + 1)) of $max_retries..."
120
+ docker buildx build --push \
121
+ --platform linux/arm64 \
122
+ --tag ${{ matrix.image.tag }}-arm64 \
123
+ -f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
124
+
125
+ count=$(($count + 1))
126
+ echo "Build failed, retrying in 5 seconds..."
127
+ sleep 5
128
+ done
129
+
130
+ if [ "$success" = false ]; then
131
+ echo "Build failed after $max_retries attempts."
132
+ exit 1
133
+ fi
80
134
81
- - name : Build and push amr64
82
- uses : docker/build-push-action@v2
83
- with :
84
- context : ${{ matrix.image.context }}
85
- file : ${{ matrix.image.dockerfile }}
86
- push : true
87
- tags : ${{ matrix.image.tag }}-arm64
88
- platforms : linux/arm64
89
-
90
135
- name : docker image
91
136
run : |
92
137
docker images
98
143
docker images
99
144
docker manifest create ${{ matrix.image.tag }} ${{ matrix.image.tag }}-arm64 ${{ matrix.image.tag }}-amd64
100
145
docker manifest inspect ${{ matrix.image.tag }}
146
+ docker manifest push ${{ matrix.image.tag }}
101
147
102
148
- name : Check disk space
103
149
run : df -h
0 commit comments