29 lines
1.7 KiB
PowerShell
29 lines
1.7 KiB
PowerShell
param(
|
|
[switch]$AllowLaptopFallback,
|
|
[string]$Droplet = '147.182.178.136',
|
|
[string]$IdentityFile = (Join-Path $env:USERPROFILE '.ssh/digitalocean')
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
if (-not $AllowLaptopFallback) {
|
|
throw 'The delivery node now runs on The-Ocean. Start a laptop fallback only after stopping the remote copy, then pass -AllowLaptopFallback. Never connect both copies of the same node.'
|
|
}
|
|
$repoPath = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
|
|
$sshArguments = @('-i', $IdentityFile, '-o', 'IdentitiesOnly=yes', '-o', 'BatchMode=yes',
|
|
'-o', 'StrictHostKeyChecking=yes', '-o', 'ConnectTimeout=10', "root@$Droplet")
|
|
& ssh @sshArguments 'docker exec -u jenkins gitea-jenkins-1 test -f /var/jenkins_home/delivery-bootstrap/configured.json'
|
|
& docker volume create ssw590-delivery-identity | Out-Null
|
|
# The generated identity flows directly from pinned administrator SSH into a
|
|
# protected Docker volume. No secret enters command arguments, output or Git.
|
|
& ssh @sshArguments 'docker exec -u jenkins gitea-jenkins-1 cat /var/jenkins_home/delivery-bootstrap/agent-secret' |
|
|
& docker run --rm -i --network none --user 0:0 --entrypoint sh `
|
|
--mount 'type=volume,source=ssw590-delivery-identity,target=/identity' `
|
|
ssw590-delivery-agent:20261114 -c 'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret'
|
|
Push-Location $repoPath
|
|
try {
|
|
& docker compose -f delivery/agent/compose.yaml up -d
|
|
& docker compose -f delivery/agent/compose.yaml ps
|
|
} finally {
|
|
Pop-Location
|
|
}
|