diff --git a/deploy-manual.ps1 b/deploy-manual.ps1 new file mode 100644 index 0000000..0f6f834 --- /dev/null +++ b/deploy-manual.ps1 @@ -0,0 +1,68 @@ +# Deploy manual corrigido (sem problemas de quebra de linha) +param( + [string]$Tag = "latest-manual" +) + +Write-Host "🏗️ Building and deploying BCards..." -ForegroundColor Green + +try { + # 1. Build da imagem + Write-Host "📦 Building Docker image..." -ForegroundColor Yellow + + # Build e push da imagem + docker buildx build --platform linux/arm64 --tag "registry.redecarneir.us/bcards:$Tag" --tag "registry.redecarneir.us/bcards:latest" --push --no-cache . + + if ($LASTEXITCODE -ne 0) { + throw "Build failed" + } + + Write-Host "✅ Image built and pushed successfully!" -ForegroundColor Green + + # 2. Deploy no servidor 1 + Write-Host "🚀 Deploying to server 1 (141.148.162.114)..." -ForegroundColor Yellow + + # Usar script inline mais simples + $deployScript1 = @' +echo "🔄 Updating server 1..." +docker stop bcards-prod || true +docker rm bcards-prod || true +docker rmi registry.redecarneir.us/bcards:latest || true +docker pull registry.redecarneir.us/bcards:latest +docker run -d --name bcards-prod --restart unless-stopped --network host -e ASPNETCORE_ENVIRONMENT=Production -e ASPNETCORE_URLS=http://+:8080 -e "MongoDb__ConnectionString=mongodb://admin:c4rn31r0@129.146.116.218:27017,141.148.162.114:27017/BCardsDB?replicaSet=rs0&authSource=admin" -e MongoDb__DatabaseName=BCardsDB -e Logging__LogLevel__Default=Debug -e Serilog__SeqUrl=http://localhost:5343 registry.redecarneir.us/bcards:latest +echo "✅ Server 1 updated" +'@ + + $deployScript1 | ssh ubuntu@141.148.162.114 'bash -s' + + # 3. Deploy no servidor 2 + Write-Host "🚀 Deploying to server 2 (129.146.116.218)..." -ForegroundColor Yellow + + $deployScript2 = @' +echo "🔄 Updating server 2..." +docker stop bcards-prod || true +docker rm bcards-prod || true +docker rmi registry.redecarneir.us/bcards:latest || true +docker pull registry.redecarneir.us/bcards:latest +docker run -d --name bcards-prod --restart unless-stopped --network host -e ASPNETCORE_ENVIRONMENT=Production -e ASPNETCORE_URLS=http://+:8080 -e "MongoDb__ConnectionString=mongodb://admin:c4rn31r0@129.146.116.218:27017,141.148.162.114:27017/BCardsDB?replicaSet=rs0&authSource=admin" -e MongoDb__DatabaseName=BCardsDB -e Logging__LogLevel__Default=Debug -e Serilog__SeqUrl=http://localhost:5342 registry.redecarneir.us/bcards:latest +echo "✅ Server 2 updated" +'@ + + $deployScript2 | ssh ubuntu@129.146.116.218 'bash -s' + + # 4. Health check + Write-Host "🏥 Running health checks..." -ForegroundColor Yellow + Start-Sleep 30 + + Write-Host "Testing server 1..." -ForegroundColor Cyan + ssh ubuntu@141.148.162.114 'curl -f http://localhost:8080/health || echo "Server 1 health check failed"' + + Write-Host "Testing server 2..." -ForegroundColor Cyan + ssh ubuntu@129.146.116.218 'curl -f http://localhost:8080/health || echo "Server 2 health check failed"' + + Write-Host "✅ Manual deploy completed successfully!" -ForegroundColor Green + Write-Host "🌐 Test your CSS changes now!" -ForegroundColor Magenta + +} catch { + Write-Host "❌ Deploy failed: $_" -ForegroundColor Red + exit 1 +} \ No newline at end of file