# One-click: Maven build -> copy JARs/SQL -> docker compose up (frontend + all backend) param( [switch]$SkipBuild, [switch]$NoImageBuild, [switch]$ResetDb, [switch]$Rebuild, [switch]$WithVendorSdk ) if ($Rebuild) { $NoImageBuild = $false } $ErrorActionPreference = "Stop" $DockerDir = $PSScriptRoot $BackendRoot = Join-Path $DockerDir ".." function Test-DockerRunning { if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { throw "Docker not found. Install Docker Desktop." } docker info 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { throw "Docker is not running. Start Docker Desktop first." } } Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " YunYan Video Monitor - One Click Start" -ForegroundColor Cyan Write-Host " Frontend (Nginx) + All Backend Services" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Test-DockerRunning if ($ResetDb) { Write-Host "[1/4] Reset MySQL data volume..." -ForegroundColor Yellow $mysqlData = Join-Path $DockerDir "mysql\data" if (Test-Path $mysqlData) { Remove-Item $mysqlData -Recurse -Force Write-Host " Removed mysql\data" -ForegroundColor Yellow } } else { Write-Host "[1/4] Skip DB reset (use -ResetDb to re-init)" -ForegroundColor DarkGray } if (-not $SkipBuild) { Write-Host "[2/4] Maven build all backend modules..." -ForegroundColor Green if (-not (Get-Command mvn -ErrorAction SilentlyContinue)) { throw "mvn not found. Install JDK 17 and Maven." } Push-Location $BackendRoot try { mvn clean package -DskipTests -T 1C if ($LASTEXITCODE -ne 0) { throw "Maven build failed" } } finally { Pop-Location } } else { Write-Host "[2/4] Skip Maven (-SkipBuild)" -ForegroundColor DarkGray } Write-Host "[3/4] Copy JARs and SQL..." -ForegroundColor Green & (Join-Path $DockerDir "copy.ps1") -SkipBuild if ($LASTEXITCODE -ne 0) { throw "copy.ps1 failed" } Write-Host "[4/4] Docker compose up (build images)..." -ForegroundColor Green Push-Location $DockerDir try { New-Item -ItemType Directory -Force -Path (Join-Path $DockerDir "ruoyi\uploadPath") | Out-Null $composeArgs = @("compose", "--env-file", ".env", "up", "-d") if (-not $NoImageBuild) { $composeArgs += "--build" } if ($WithVendorSdk) { $composeArgs += "--profile" $composeArgs += "vendor-sdk" Write-Host " vendor-sdk: Hikvision/Dahua (requires vendor .so/.dll under ruoyi-modules/*/lib)" -ForegroundColor Yellow } else { Write-Host " Default: skip Hikvision/Dahua SDK containers (no native libs in image)." -ForegroundColor DarkGray } & docker @composeArgs if ($LASTEXITCODE -ne 0) { throw "docker compose failed" } Write-Host "" Write-Host "Waiting for core services (60-120s)..." -ForegroundColor Yellow $deadline = (Get-Date).AddMinutes(8) $ready = $false while ((Get-Date) -lt $deadline) { $nacos = docker inspect --format='{{.State.Health.Status}}' ruoyi-nacos 2>$null $gw = docker inspect --format='{{.State.Status}}' ruoyi-gateway 2>$null $ngx = docker inspect --format='{{.State.Status}}' ruoyi-nginx 2>$null if ($nacos -eq "healthy" -and $gw -eq "running" -and $ngx -eq "running") { $ready = $true break } Start-Sleep -Seconds 5 Write-Host " ... nacos=$nacos gateway=$gw nginx=$ngx" -ForegroundColor DarkGray } } finally { Pop-Location } Write-Host "" Write-Host "========================================" -ForegroundColor Green if ($ready) { Write-Host " Ready" -ForegroundColor Green } else { Write-Host " Containers started; some may still be booting" -ForegroundColor Yellow Write-Host " Check: docker compose ps" -ForegroundColor Yellow } Write-Host "========================================" -ForegroundColor Green Write-Host " Web UI : http://localhost" Write-Host " Gateway : http://localhost:8080" Write-Host " Nacos : http://localhost:8848/nacos" Write-Host " Login : admin / admin123" Write-Host "" Write-Host " Stop : .\stop.ps1" Write-Host " Restart : .\start.ps1 -SkipBuild -NoImageBuild" Write-Host " Hik/Dahua: .\start.ps1 -WithVendorSdk (Windows native SDK only)" Write-Host "========================================" Write-Host ""