build(deploy): switch hosting to Podman Quadlet
This commit is contained in:
1 parent
10aa0304e4
commit
019b15041a
15 files changed
+312
-134
No files matched your search
@@ -0,0 +1,39 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function ConvertTo-WslPath([string]$Path) {
|
||||
$fullPath = [IO.Path]::GetFullPath($Path)
|
||||
if ($fullPath -notmatch '^([A-Za-z]):\\(.*)$') { throw "Workspace must be on a Windows drive: $fullPath" }
|
||||
$drive = $Matches[1].ToLowerInvariant()
|
||||
$relative = $Matches[2].Replace('\', '/')
|
||||
return "/mnt/$drive/$relative"
|
||||
}
|
||||
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||
$repoWsl = ConvertTo-WslPath $repoRoot
|
||||
|
||||
$unitPath = (Resolve-Path (Join-Path $PSScriptRoot '..\deploy\webdrop.container')).Path
|
||||
$unitWsl = ConvertTo-WslPath $unitPath
|
||||
|
||||
$updatePath = (Resolve-Path (Join-Path $PSScriptRoot 'wsl-podman-update.sh')).Path
|
||||
$updateWsl = ConvertTo-WslPath $updatePath
|
||||
|
||||
$commit = (& git -C $repoRoot rev-parse --short=12 HEAD).Trim()
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not read the current Git commit.' }
|
||||
$tagOutput = & git -C $repoRoot describe --tags --exact-match HEAD 2>$null
|
||||
$tag = if ($tagOutput) { "$tagOutput".Trim() } else { 'dev' }
|
||||
$buildTime = [TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([DateTimeOffset]::UtcNow, 'China Standard Time').ToString('yyyy-MM-dd HH:mm')
|
||||
|
||||
$deployHome = '/home/justme/podman/webdrop'
|
||||
$configDir = '/home/justme/.config/containers/systemd'
|
||||
& wsl.exe -d Debian -- mkdir -p $deployHome $configDir
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not create the WSL deployment directories.' }
|
||||
|
||||
& wsl.exe -d Debian -- install -D -m 755 $updateWsl "$deployHome/update.sh"
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not install the WSL update script.' }
|
||||
& wsl.exe -d Debian -- install -D -m 644 $unitWsl "$deployHome/webdrop.container"
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not install the WebDrop Quadlet.' }
|
||||
& wsl.exe -d Debian -- ln -sfn "$deployHome/webdrop.container" "$configDir/webdrop.container"
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not link the Quadlet into the user systemd directory.' }
|
||||
|
||||
& wsl.exe -d Debian -- bash "$deployHome/update.sh" $repoWsl $commit $tag $buildTime
|
||||
if ($LASTEXITCODE -ne 0) { throw 'The WSL Podman build or service update failed.' }
|
||||
Reference in new issue
Block a user