# 閰嶇疆楠岃瘉鑴氭湰 # PetWash API Docker 閮ㄧ讲鍓嶆鏌? Write-Host "======================================" -ForegroundColor Cyan Write-Host "PetWash API 閰嶇疆楠岃瘉" -ForegroundColor Cyan Write-Host "======================================" -ForegroundColor Cyan Write-Host "" $allPassed = $true # 1. 妫€鏌?Docker Write-Host "1. 妫€鏌?Docker..." -ForegroundColor Yellow try { $dockerVersion = docker --version 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host " [OK] Docker 宸插畨瑁? $dockerVersion" -ForegroundColor Green } else { Write-Host " [FAIL] Docker 鏈畨瑁? -ForegroundColor Red $allPassed = $false } } catch { Write-Host " [FAIL] Docker 鏈畨瑁? -ForegroundColor Red $allPassed = $false } # 2. 妫€鏌?Docker Compose Write-Host "2. 妫€鏌?Docker Compose..." -ForegroundColor Yellow try { $composeVersion = docker-compose --version 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host " [OK] Docker Compose 宸插畨瑁? $composeVersion" -ForegroundColor Green } else { Write-Host " [FAIL] Docker Compose 鏈畨瑁? -ForegroundColor Red $allPassed = $false } } catch { Write-Host " [FAIL] Docker Compose 鏈畨瑁? -ForegroundColor Red $allPassed = $false } # 3. 妫€鏌ラ厤缃枃浠? Write-Host "3. 妫€鏌ラ厤缃枃浠?.." -ForegroundColor Yellow $configFiles = @( "PetWash.Api/Dockerfile", "docker-compose.yml", "PetWash.Api/appsettings.json", "PetWash.Api/appsettings.Production.json", "init-database.sql" ) foreach ($file in $configFiles) { if (Test-Path $file) { Write-Host " [OK] $file 瀛樺湪" -ForegroundColor Green } else { Write-Host " [FAIL] $file 涓嶅瓨鍦? -ForegroundColor Red $allPassed = $false } } # 4. 妫€鏌?MySQL 鍖? Write-Host "4. 妫€鏌?NuGet 鍖?.." -ForegroundColor Yellow $csprojContent = Get-Content "PetWash.Api/PetWash.Api.csproj" -Raw if ($csprojContent -match "Pomelo.EntityFrameworkCore.MySql") { Write-Host " [OK] MySQL 鍖呭凡娣诲姞" -ForegroundColor Green } else { Write-Host " [FAIL] MySQL 鍖呮湭娣诲姞" -ForegroundColor Red $allPassed = $false } # 5. 妫€鏌?MySQL 杩炴帴 Write-Host "5. 妫€鏌?MySQL 杩炴帴..." -ForegroundColor Yellow $mysqlHost = "101.132.182.216" $mysqlPort = 3306 try { $tcpClient = New-Object System.Net.Sockets.TcpClient $tcpClient.Connect($mysqlHost, $mysqlPort) $tcpClient.Close() Write-Host " [OK] MySQL 鏈嶅姟鍣ㄥ彲璁块棶" -ForegroundColor Green } catch { Write-Host " [FAIL] MySQL 鏈嶅姟鍣ㄤ笉鍙闂? -ForegroundColor Red Write-Host " 璇锋鏌ョ綉缁滆繛鎺ュ拰闃茬伀澧欒缃? -ForegroundColor Yellow $allPassed = $false } # 6. 妫€鏌ラ」鐩紪璇? Write-Host "6. 妫€鏌ラ」鐩紪璇?.." -ForegroundColor Yellow try { Push-Location "PetWash.Api" $buildResult = dotnet build --no-restore 2>&1 Pop-Location if ($LASTEXITCODE -eq 0) { Write-Host " [OK] 椤圭洰缂栬瘧鎴愬姛" -ForegroundColor Green } else { Write-Host " [FAIL] 椤圭洰缂栬瘧澶辫触" -ForegroundColor Red $allPassed = $false } } catch { Write-Host " [FAIL] 椤圭洰缂栬瘧澶辫触" -ForegroundColor Red $allPassed = $false Pop-Location } # 鎬荤粨 Write-Host "" Write-Host "======================================" -ForegroundColor Cyan if ($allPassed) { Write-Host "[SUCCESS] 鎵€鏈夋鏌ラ€氳繃锛佸彲浠ュ紑濮嬮儴缃? -ForegroundColor Green Write-Host "" Write-Host "涓嬩竴姝?" -ForegroundColor Yellow Write-Host "1. 鍒濆鍖栨暟鎹簱" -ForegroundColor White Write-Host " mysql -h 101.132.182.216 -P 3306 -u root -p" -ForegroundColor Gray Write-Host " 鐒跺悗杩愯: SOURCE init-database.sql" -ForegroundColor Gray Write-Host "2. 杩愯閮ㄧ讲鑴氭湰: .\deploy.ps1" -ForegroundColor White } else { Write-Host "[FAILED] 閮ㄥ垎妫€鏌ユ湭閫氳繃锛岃淇鍚庡啀閮ㄧ讲" -ForegroundColor Red } Write-Host "======================================" -ForegroundColor Cyan