优化 Docker 镜像构建过程,增加重试机制以提高构建稳定性
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Successful in 1m53s
Docker Build & Deploy / Deploy to Production (push) Failing after 6s

This commit is contained in:
2026-01-01 14:45:12 +08:00
parent e00b5cffb7
commit c58404491f

View File

@@ -27,7 +27,19 @@ jobs:
docker rmi $IMAGE_NAME || true
- 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:
name: Deploy to Production