|
29 | 29 | docker-compose --file docker-compose.test.yml build |
30 | 30 | docker-compose --file docker-compose.test.yml run sut |
31 | 31 | else |
32 | | - docker buildx build . --file Dockerfile --platform linux/amd64,linux/arm64 |
| 32 | + # Add retry logic for docker buildx |
| 33 | + max_attempts=3 |
| 34 | + attempt=1 |
| 35 | + while [ $attempt -le $max_attempts ]; do |
| 36 | + echo "Attempt $attempt of $max_attempts for docker buildx build" |
| 37 | + if docker buildx build . --file Dockerfile --platform linux/amd64; then |
| 38 | + echo "Build successful!" |
| 39 | + break |
| 40 | + else |
| 41 | + echo "Build failed on attempt $attempt" |
| 42 | + if [ $attempt -eq $max_attempts ]; then |
| 43 | + echo "All attempts failed. Exiting." |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + echo "Waiting 30 seconds before retrying..." |
| 47 | + sleep 30 |
| 48 | + ((attempt++)) |
| 49 | + fi |
| 50 | + done |
33 | 51 | fi |
34 | 52 | # Push image to GitHub Packages. |
35 | 53 | # See also https://docs.docker.com/docker-hub/builds/ |
|
61 | 79 | echo IMAGE_ID=$IMAGE_ID |
62 | 80 | echo VERSION=$VERSION |
63 | 81 | |
64 | | - # Build and push multi-arch image |
65 | | - docker buildx build . \ |
66 | | - --platform linux/amd64,linux/arm64 \ |
67 | | - --file Dockerfile \ |
68 | | - --tag $IMAGE_ID:$VERSION \ |
69 | | - --push |
| 82 | + # Build and push with retry logic |
| 83 | + max_attempts=3 |
| 84 | + attempt=1 |
| 85 | + while [ $attempt -le $max_attempts ]; do |
| 86 | + echo "Attempt $attempt of $max_attempts for docker buildx build and push" |
| 87 | + if docker buildx build . \ |
| 88 | + --platform linux/amd64,linux/arm64 \ |
| 89 | + --file Dockerfile \ |
| 90 | + --tag $IMAGE_ID:$VERSION \ |
| 91 | + --push; then |
| 92 | + echo "Build and push successful!" |
| 93 | + break |
| 94 | + else |
| 95 | + echo "Build and push failed on attempt $attempt" |
| 96 | + if [ $attempt -eq $max_attempts ]; then |
| 97 | + echo "All attempts failed. Exiting." |
| 98 | + exit 1 |
| 99 | + fi |
| 100 | + echo "Waiting 30 seconds before retrying..." |
| 101 | + sleep 30 |
| 102 | + ((attempt++)) |
| 103 | + fi |
| 104 | + done |
0 commit comments