Param() function Start-DockerDesktopIfNeeded { $proc = Get-Process -Name 'Docker Desktop' -ErrorAction SilentlyContinue if (-not $proc) { $exe = 'C:\Program Files\Docker\Docker\Docker Desktop.exe' if (Test-Path $exe) { Write-Host "Starting Docker Desktop from $exe ..." Start-Process -FilePath $exe } else { Write-Host "Docker Desktop executable not found at $exe" -ForegroundColor Yellow } } else { Write-Host 'Docker Desktop already running.' } } function Wait-For-Docker { param( [int]$TimeoutSec = 120 ) $interval = 2 $tries = [math]::Ceiling($TimeoutSec / $interval) for ($i = 0; $i -lt $tries; $i++) { try { docker version > $null 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host 'Docker daemon is ready.' return $true } } catch { # ignore } Start-Sleep -Seconds $interval } Write-Host 'Timed out waiting for Docker daemon.' -ForegroundColor Red return $false } try { Start-DockerDesktopIfNeeded $ready = Wait-For-Docker -TimeoutSec 120 if (-not $ready) { exit 20 } Write-Host 'Building and starting docker-compose.dev.yml (detached)...' Push-Location (Resolve-Path "${PSScriptRoot}\..") $composeFile = 'docker-compose.dev.yml' docker compose -f $composeFile up -d --build $exit = $LASTEXITCODE if ($exit -ne 0) { Write-Host "docker compose failed with exit code $exit" -ForegroundColor Red Pop-Location exit $exit } Start-Sleep -Seconds 4 Write-Host "Health check: GET /" try { $h = Invoke-RestMethod -Uri http://localhost:8000/ -UseBasicParsing -TimeoutSec 5 Write-Host 'HEALTH:' $h | ConvertTo-Json -Depth 5 | Write-Host } catch { Write-Host "Health check failed: $($_.Exception.Message)" -ForegroundColor Yellow } Write-Host "Docs check: GET /docs" try { $d = Invoke-WebRequest -Uri http://localhost:8000/docs -UseBasicParsing -TimeoutSec 5 if ($d.StatusCode -eq 200) { Write-Host 'DOCS: OK (HTML returned)' } } catch { Write-Host "Docs check failed: $($_.Exception.Message)" -ForegroundColor Yellow } Write-Host '--- Server logs (last 200 lines) ---' docker compose -f $composeFile logs --no-log-prefix --tail 200 server Write-Host '--- Web logs (last 200 lines) ---' docker compose -f $composeFile logs --no-log-prefix --tail 200 web Pop-Location Write-Host 'Done.' } catch { Write-Host "Script error: $($_.Exception.Message)" -ForegroundColor Red exit 1 }