Refresh deploy/ and bin/ from the boilerplate at 09e144d (the release split between the distro and Windows, wsl-setup, the server config, USER 1000, python:3.15-slim) with roledesk's facts put back: no frontend stage, desk, plugins and seed copied, the extras passkeys, embeddings and llm, roles as the table the backup and the importer require, bin/pull.sh and bin/worker.sh with their profile commands, and Install Server.md and Install WSL.md as copies in place of the five old deployment docs
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
83e965dfeb
commit
a1f281a23a
40 files changed
+2226
-1287
No files matched your search
+22
-66
@@ -1,76 +1,32 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Shared plumbing for the release scripts. Dot-source it; do not run it.
|
||||
|
||||
.DESCRIPTION
|
||||
Dot-sourcing runs in the caller's scope, so everything defined here --
|
||||
$root, $settings, Setting, Assert-Ok, Write-Step, Remove-ReleaseTemp -- is
|
||||
the caller's afterwards. One copy of the release.env reader, because three
|
||||
copies is three places for it to drift.
|
||||
#>
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
# Dot-sourced by 2-build-image.ps1 and 3-push-image.ps1. Reads deploy\release.env
|
||||
# beside it (KEY=VALUE lines, # comments, never run as code) into $Settings,
|
||||
# and works out where step 1 exported the release: release\<folder> beside the
|
||||
# checkout, in the distro, seen from Windows through \\wsl.localhost.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
#: The repository root, worked out from this file rather than from the working
|
||||
#: directory, so the scripts can be run from anywhere.
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
#: A checkout inside WSL, run from Windows as \\wsl.localhost\<distro>\... Its
|
||||
#: .venv is a Linux one, so the steps that run Python hand that part to the
|
||||
#: distro. $Wsl.Groups[1] is the distro; ConvertTo-LinuxPath turns a path under
|
||||
#: the checkout into the distro's own. See docs/wsl.md.
|
||||
$WslPattern = '^\\\\wsl(?:\.localhost|\$)\\([^\\]+)(\\.*)$'
|
||||
$Wsl = [regex]::Match($root, $WslPattern)
|
||||
function ConvertTo-LinuxPath([string] $Path) {
|
||||
[regex]::Match($Path, $WslPattern).Groups[2].Value -replace '\\', '/'
|
||||
}
|
||||
|
||||
function Assert-Ok([string] $What) {
|
||||
if ($LASTEXITCODE -ne 0) { throw "$What failed (exit $LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
function Write-Step([string] $Text) {
|
||||
Write-Host ''
|
||||
Write-Host "== $Text" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$envFile = Join-Path $PSScriptRoot 'release.env'
|
||||
if (-not (Test-Path $envFile)) {
|
||||
throw "no deploy\release.env - copy deploy\release.env.example and fill it in"
|
||||
}
|
||||
$settings = @{}
|
||||
if (-not (Test-Path $envFile)) { throw "no $envFile - copy release.env.example and fill it in" }
|
||||
$Settings = @{}
|
||||
foreach ($line in Get-Content $envFile) {
|
||||
if ($line -match '^\s*(#|$)') { continue }
|
||||
# A line with no `=` is a typo, not a setting. Say so here rather than
|
||||
# letting it surface later as a null reference three functions away.
|
||||
if ($line -notmatch '=') { throw "release.env: not a KEY=VALUE line: $line" }
|
||||
$key, $value = $line -split '=', 2
|
||||
$settings[$key.Trim()] = $value.Trim().Trim('"')
|
||||
$Settings[$key.Trim()] = "$value".Trim().Trim('"')
|
||||
}
|
||||
|
||||
function Setting([string] $Name, [string] $Default, [switch] $Required) {
|
||||
if ($settings.ContainsKey($Name) -and $settings[$Name]) { return $settings[$Name] }
|
||||
if ($Required) { throw "set $Name in deploy\release.env" }
|
||||
return $Default
|
||||
foreach ($key in 'DISTRO', 'CHECKOUT', 'IMAGE') {
|
||||
if (-not $Settings[$key]) { throw "set $key in $envFile" }
|
||||
}
|
||||
$Image = $Settings.IMAGE
|
||||
$Checkout = $Settings.CHECKOUT.TrimEnd('/')
|
||||
$Release = "\\wsl.localhost\$($Settings.DISTRO)" + ($Checkout -replace '/[^/]+$', '' -replace '/', '\') + '\release\' + ($Checkout -replace '^.*/', '')
|
||||
|
||||
#: What temporary directories this release is allowed to delete. Everything
|
||||
#: below is created by these scripts and named for it.
|
||||
$Name = Setting NAME -Required
|
||||
|
||||
# Only ever deletes a <name>-* entry directly under the temp directory. A
|
||||
# guard, not a convenience: these paths are built by string concatenation and
|
||||
# handed to `Remove-Item -Recurse -Force`, and one empty variable in that
|
||||
# sentence is a very bad afternoon.
|
||||
function Remove-ReleaseTemp([string[]] $Paths) {
|
||||
$tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('\') + '\'
|
||||
foreach ($path in $Paths) {
|
||||
$resolved = [IO.Path]::GetFullPath($path)
|
||||
if (-not $resolved.StartsWith($tempRoot, [StringComparison]::OrdinalIgnoreCase) -or
|
||||
-not ([IO.Path]::GetFileName($resolved)).StartsWith("$Name-")) {
|
||||
throw "Unsafe release temporary path: $resolved"
|
||||
}
|
||||
if (Test-Path -LiteralPath $resolved) { Remove-Item -LiteralPath $resolved -Recurse -Force }
|
||||
function Assert-Wslc {
|
||||
if (-not (Get-Command wslc -ErrorAction SilentlyContinue)) {
|
||||
throw 'wslc is not on PATH - run wsl --update (WSL 2.9.3 or later), see https://learn.microsoft.com/windows/wsl/tutorials/wsl-containers'
|
||||
}
|
||||
}
|
||||
|
||||
# The tag step 1 exported, from release\<folder>\production.
|
||||
function Get-ReleaseSha {
|
||||
$file = Join-Path $Release 'production'
|
||||
if (-not (Test-Path $file)) { throw "no $file - run step 1 first" }
|
||||
(Get-Content $file -TotalCount 1).Trim()
|
||||
}
|
||||
Reference in new issue
Block a user