Files
petwash/check-deployment.ps1
2026-03-03 16:49:57 +08:00

84 lines
2.3 KiB
PowerShell

# PetWash API Deployment Check Script
Write-Host "======================================"
Write-Host "PetWash API Deployment Check"
Write-Host "======================================"
Write-Host ""
# Check Docker
Write-Host "Checking Docker..."
docker --version
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] Docker is installed" -ForegroundColor Green
} else {
Write-Host "[FAIL] Docker is not installed" -ForegroundColor Red
}
# Check Docker Compose
Write-Host ""
Write-Host "Checking Docker Compose..."
docker-compose --version
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] Docker Compose is installed" -ForegroundColor Green
} else {
Write-Host "[FAIL] Docker Compose is not installed" -ForegroundColor Red
}
# Check files
Write-Host ""
Write-Host "Checking configuration files..."
$files = @(
"PetWash.Api/Dockerfile",
"docker-compose.yml",
"PetWash.Api/appsettings.json",
"PetWash.Api/appsettings.Production.json",
"init-database.sql"
)
foreach ($f in $files) {
if (Test-Path $f) {
Write-Host "[OK] $f" -ForegroundColor Green
} else {
Write-Host "[FAIL] $f not found" -ForegroundColor Red
}
}
# Check MySQL package
Write-Host ""
Write-Host "Checking MySQL package..."
$content = Get-Content "PetWash.Api/PetWash.Api.csproj" -Raw
if ($content -match "Pomelo.EntityFrameworkCore.MySql") {
Write-Host "[OK] MySQL package is added" -ForegroundColor Green
} else {
Write-Host "[FAIL] MySQL package is missing" -ForegroundColor Red
}
# Check MySQL connection
Write-Host ""
Write-Host "Checking MySQL connection..."
try {
$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.Connect("101.132.182.216", 3306)
$tcp.Close()
Write-Host "[OK] MySQL server is accessible" -ForegroundColor Green
} catch {
Write-Host "[FAIL] Cannot connect to MySQL server" -ForegroundColor Red
}
# Check build
Write-Host ""
Write-Host "Checking project build..."
Push-Location "PetWash.Api"
dotnet build --no-restore > $null 2>&1
Pop-Location
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] Project builds successfully" -ForegroundColor Green
} else {
Write-Host "[FAIL] Project build failed" -ForegroundColor Red
}
Write-Host ""
Write-Host "======================================"
Write-Host "Check complete!"
Write-Host "======================================"