优化 Docker 镜像构建过程,增加重试机制以提高构建稳定性
This commit is contained in:
@@ -27,7 +27,19 @@ jobs:
|
|||||||
docker rmi $IMAGE_NAME || true
|
docker rmi $IMAGE_NAME || true
|
||||||
|
|
||||||
- name: Build new image
|
- name: Build new image
|
||||||
run: docker build -t $IMAGE_NAME .
|
run: |
|
||||||
|
RETRIES=3
|
||||||
|
DELAY=10
|
||||||
|
count=0
|
||||||
|
until docker build -t $IMAGE_NAME .; do
|
||||||
|
count=$((count+1))
|
||||||
|
if [ $count -ge $RETRIES ]; then
|
||||||
|
echo "Build failed after $RETRIES attempts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Build failed. Retrying in $DELAY seconds... ($count/$RETRIES)"
|
||||||
|
sleep $DELAY
|
||||||
|
done
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Production
|
name: Deploy to Production
|
||||||
|
|||||||
Reference in New Issue
Block a user