# perinco CRM - Deployment auf 212.227.135.41 # # Baut lokal und laedt nur dist/ plus Backend-Quellen hoch. Auf dem Server wird # absichtlich nicht gebaut: dort sind RAM und Swap knapp. # # Aufruf aus dem Projektverzeichnis: # powershell -File deploy/deploy.ps1 # powershell -File deploy/deploy.ps1 -SkipBuild # powershell -File deploy/deploy.ps1 -Deps # bei neuen Backend-Paketen param( [string]$ServerHost = '212.227.135.41', [int]$Port = 4345, [string]$User = 'root', [string]$Password = $env:PERINCO_CRM_SSH_PASSWORD, [string]$RemotePath = '/var/www/perinco_CRM', [switch]$SkipBuild, [switch]$Deps ) $ErrorActionPreference = 'Stop' if (-not $Password) { throw 'Kein Passwort. Setze $env:PERINCO_CRM_SSH_PASSWORD oder uebergib -Password.' } $plink = 'C:\Program Files\PuTTY\plink.exe' $pscp = 'C:\Program Files\PuTTY\pscp.exe' foreach ($tool in @($plink, $pscp)) { if (-not (Test-Path $tool)) { throw "Nicht gefunden: $tool" } } $projectRoot = Split-Path -Parent $PSScriptRoot Set-Location $projectRoot if (-not $SkipBuild) { Write-Host '==> Frontend bauen' -ForegroundColor Green npm run build if ($LASTEXITCODE -ne 0) { throw 'Build fehlgeschlagen - es wird nichts hochgeladen.' } } $target = "$User@$ServerHost" Write-Host '==> dist/ hochladen' -ForegroundColor Green & $pscp -r -batch -P $Port -pw $Password 'dist' "${target}:$RemotePath/" Write-Host '==> Backend hochladen' -ForegroundColor Green & $pscp -r -batch -P $Port -pw $Password 'server\src' "${target}:$RemotePath/server/" & $pscp -batch -P $Port -pw $Password 'server\package.json' "${target}:$RemotePath/server/" $remoteCommand = "systemctl restart perinco-crm-backend; sleep 3; systemctl is-active perinco-crm-backend; curl -s http://127.0.0.1:5006/api/health" if ($Deps) { $remoteCommand = "cd $RemotePath/server && npm install --omit=dev --no-audit --no-fund; $remoteCommand" } Write-Host '==> Backend neu starten und pruefen' -ForegroundColor Green & $plink -ssh -batch -P $Port -pw $Password $target $remoteCommand Write-Host '' Write-Host 'Fertig.' -ForegroundColor Green