| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- # Copy backend JARs and SQL (frontend is built in nginx Dockerfile)
- param([switch]$SkipBuild)
- $ErrorActionPreference = "Stop"
- $DockerDir = $PSScriptRoot
- $BackendRoot = Join-Path $DockerDir ".."
- function Ensure-Dir([string]$Path) {
- if (-not (Test-Path $Path)) { New-Item -ItemType Directory -Path $Path -Force | Out-Null }
- }
- Write-Host "=== SQL ===" -ForegroundColor Cyan
- $DbDir = Join-Path $DockerDir "mysql\db"
- Ensure-Dir $DbDir
- @(
- @{ Out = "01-ry-config.sql"; Db = "ry-config"; Src = "sql\ry-config.sql" }
- @{ Out = "02-ry-cloud.sql"; Db = "ry-cloud"; Src = "sql\ry-cloud.sql" }
- ) | ForEach-Object {
- $srcPath = Join-Path $BackendRoot $_.Src
- if (-not (Test-Path $srcPath)) { throw "Missing: $srcPath" }
- $lines = @("USE ``$($_.Db)``;"; "") + (Get-Content $srcPath -Encoding UTF8)
- $lines | Set-Content (Join-Path $DbDir $_.Out) -Encoding UTF8
- Write-Host ("OK: " + $_.Out)
- }
- if (-not $SkipBuild) {
- Write-Host "=== Maven build ===" -ForegroundColor Cyan
- 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
- }
- }
- Write-Host "=== JARs ===" -ForegroundColor Cyan
- $jars = @(
- @{ Src = "ruoyi-gateway\target\ruoyi-gateway.jar"; Dest = "ruoyi\gateway\jar" }
- @{ Src = "ruoyi-auth\target\ruoyi-auth.jar"; Dest = "ruoyi\auth\jar" }
- @{ Src = "ruoyi-visual\ruoyi-monitor\target\ruoyi-visual-monitor.jar"; Dest = "ruoyi\visual\monitor\jar" }
- @{ Src = "ruoyi-modules\ruoyi-system\target\ruoyi-modules-system.jar"; Dest = "ruoyi\modules\system\jar" }
- @{ Src = "ruoyi-modules\ruoyi-file\target\ruoyi-modules-file.jar"; Dest = "ruoyi\modules\file\jar" }
- @{ Src = "ruoyi-modules\ruoyi-job\target\ruoyi-modules-job.jar"; Dest = "ruoyi\modules\job\jar" }
- @{ Src = "ruoyi-modules\ruoyi-gen\target\ruoyi-modules-gen.jar"; Dest = "ruoyi\modules\gen\jar" }
- @{ Src = "ruoyi-modules\ruoyi-haikang\target\ruoyi-modules-haikang.jar"; Dest = "ruoyi\modules\haikang\jar" }
- @{ Src = "ruoyi-modules\ruoyi-qs\target\ruoyi-modules-qs.jar"; Dest = "ruoyi\modules\qs\jar" }
- @{ Src = "ruoyi-modules\ruoyi-haikang-isup\target\ruoyi-modules-haikang-isup.jar"; Dest = "ruoyi\modules\haikang-isup\jar" }
- @{ Src = "ruoyi-modules\ruoyi-dahua\target\ruoyi-modules-dahua.jar"; Dest = "ruoyi\modules\dahua\jar" }
- @{ Src = "ruoyi-modules\ruoyi-onvif\target\ruoyi-modules-onvif.jar"; Dest = "ruoyi\modules\onvif\jar" }
- @{ Src = "ruoyi-modules\ruoyi-gb28181\target\ruoyi-modules-gb28181.jar"; Dest = "ruoyi\modules\gb28181\jar" }
- @{ Src = "ruoyi-modules\ruoyi-jt1078\target\ruoyi-modules-jt1078.jar"; Dest = "ruoyi\modules\jt1078\jar" }
- @{ Src = "ruoyi-modules\ruoyi-zlm\target\ruoyi-modules-zlm.jar"; Dest = "ruoyi\modules\zlm\jar" }
- )
- $missing = [System.Collections.Generic.List[string]]::new()
- $copied = 0
- foreach ($item in $jars) {
- $src = Join-Path $BackendRoot $item.Src
- $destDir = Join-Path $DockerDir $item.Dest
- if (-not (Test-Path $src)) {
- $missing.Add($item.Src)
- continue
- }
- Ensure-Dir $destDir
- $jarName = Split-Path $src -Leaf
- Copy-Item $src (Join-Path $destDir $jarName) -Force
- Write-Host ("OK: " + $jarName)
- $copied++
- }
- if ($copied -eq 0) {
- Write-Host ""
- Write-Host "No JAR files found. Run full build first:" -ForegroundColor Red
- Write-Host " .\start.ps1" -ForegroundColor Yellow
- Write-Host "or:" -ForegroundColor Yellow
- Write-Host " cd .." -ForegroundColor Yellow
- Write-Host " mvn clean package -DskipTests" -ForegroundColor Yellow
- if ($missing.Count -gt 0) {
- Write-Host ""
- Write-Host "Missing:" -ForegroundColor Red
- $missing | ForEach-Object { Write-Host (" - " + $_) }
- }
- throw "No JAR copied."
- }
- if ($missing.Count -gt 0) {
- Write-Host ""
- Write-Host ("Warning: " + $missing.Count + " JAR(s) missing (optional modules may be skipped):") -ForegroundColor Yellow
- $missing | ForEach-Object { Write-Host (" - " + $_) }
- }
- Write-Host ("Done. Copied " + $copied + " JAR(s).") -ForegroundColor Green
|