BCards/deploy-manual.ps1
Ricardo Carneiro bd90f7b064
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 2s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 15m4s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m15s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
feat: script para deploy manual
2025-08-30 22:39:37 -03:00

68 lines
3.1 KiB
PowerShell

# 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
}