-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush-retry.ps1
More file actions
40 lines (35 loc) · 1.37 KB
/
push-retry.ps1
File metadata and controls
40 lines (35 loc) · 1.37 KB
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
# PowerShell script to retry Docker push with backoff
param(
[string]$ImageName = "smukherjee2004/ai-github-analyzer:latest",
[int]$MaxRetries = 5
)
$RetryCount = 0
Write-Host "🚀 Starting Docker push with retry logic..." -ForegroundColor Green
while ($RetryCount -lt $MaxRetries) {
$Attempt = $RetryCount + 1
Write-Host "📦 Attempt $Attempt of $MaxRetries" -ForegroundColor Yellow
try {
$result = docker push $ImageName 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Successfully pushed $ImageName to Docker Hub!" -ForegroundColor Green
exit 0
} else {
throw "Docker push failed with exit code $LASTEXITCODE"
}
}
catch {
$RetryCount++
if ($RetryCount -lt $MaxRetries) {
$WaitTime = $RetryCount * 30
Write-Host "❌ Push failed. Waiting $WaitTime seconds before retry..." -ForegroundColor Red
Start-Sleep -Seconds $WaitTime
}
}
}
Write-Host "❌ Failed to push after $MaxRetries attempts" -ForegroundColor Red
Write-Host "💡 Try the following:" -ForegroundColor Cyan
Write-Host " 1. Check your internet connection"
Write-Host " 2. Make sure you're logged into Docker Hub: docker login"
Write-Host " 3. Try pushing during off-peak hours"
Write-Host " 4. Consider using the local build option in docker-compose.yml"
exit 1