Files
QMAX/scripts/deploy-rpi.ps1
T
2026-07-07 22:09:18 +03:00

58 lines
1.8 KiB
PowerShell

param(
[string]$HostName = "195.216.241.165",
[int]$Port = 2222,
[string]$User = "sevenhill",
[string]$RemoteDir = "/home/sevenhill/qmax"
)
$ErrorActionPreference = "Stop"
Write-Host "This script prepares QMAX files for Raspberry Pi deployment."
Write-Host "It intentionally does not contain or echo SSH passwords."
Write-Host "Prerequisites on the Pi: Docker Engine, Docker Compose plugin, DNS A record for qmax.kusoft.xyz."
$archive = Join-Path $env:TEMP "qmax-deploy.tar.gz"
if (Test-Path $archive) {
Remove-Item -LiteralPath $archive -Force
}
$root = Resolve-Path "$PSScriptRoot\.."
$staging = Join-Path $env:TEMP "qmax-deploy-staging"
if (Test-Path $staging) {
Remove-Item -LiteralPath $staging -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $staging | Out-Null
foreach ($item in @("server", "pymax-worker", "deploy", "Dockerfile.server", "QMax.slnx")) {
Copy-Item -LiteralPath (Join-Path $root $item) -Destination $staging -Recurse -Force
}
foreach ($path in @(
"server/QMax.Api/bin",
"server/QMax.Api/obj",
"deploy/releases",
"pymax-worker/src/__pycache__"
)) {
$target = Join-Path $staging $path
if (Test-Path $target) {
Remove-Item -LiteralPath $target -Recurse -Force
}
}
Push-Location $staging
try {
tar -czf $archive server pymax-worker deploy Dockerfile.server QMax.slnx
}
finally {
Pop-Location
}
Write-Host "Archive created: $archive"
Write-Host "Upload:"
Write-Host " scp -P $Port $archive ${User}@${HostName}:/tmp/qmax-deploy.tar.gz"
Write-Host "Remote install/update:"
Write-Host " ssh -p $Port ${User}@${HostName}"
Write-Host " mkdir -p $RemoteDir && tar -xzf /tmp/qmax-deploy.tar.gz -C $RemoteDir"
Write-Host " cd $RemoteDir/deploy && test -f .env || cp .env.example .env && nano .env"
Write-Host " docker compose up -d --build"