chore: add registry auth credentials

This commit is contained in:
ginnoir
2026-06-14 22:53:22 -05:00
parent 0b58c11f2b
commit 3918f24970
2 changed files with 50 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
[CmdletBinding()]
param(
[string]$OutputDirectory = (Join-Path $env:TEMP "valhalla-registry-auth"),
[string]$PushUser = "registry_push",
[string]$PullUser = "registry_pull"
)
$ErrorActionPreference = "Stop"
function New-Secret {
$bytes = New-Object byte[] 32
[System.Security.Cryptography.RandomNumberGenerator]::Fill($bytes)
return [Convert]::ToBase64String($bytes).TrimEnd("=")
}
New-Item -ItemType Directory -Force -Path $OutputDirectory | Out-Null
$pushPassword = New-Secret
$pullPassword = New-Secret
$htpasswdPath = Join-Path $OutputDirectory "htpasswd"
$envPath = Join-Path $OutputDirectory "registry.env"
$pushLine = docker run --rm --entrypoint htpasswd httpd:2 -Bbn $PushUser $pushPassword
$pullLine = docker run --rm --entrypoint htpasswd httpd:2 -Bbn $PullUser $pullPassword
Set-Content -LiteralPath $htpasswdPath -NoNewline -Value ($pushLine + "`n" + $pullLine + "`n")
Set-Content -LiteralPath $envPath -NoNewline -Value @"
REGISTRY_PUSH_USERNAME=$PushUser
REGISTRY_PUSH_PASSWORD=$pushPassword
REGISTRY_PULL_USERNAME=$PullUser
REGISTRY_PULL_PASSWORD=$pullPassword
"@
Write-Host "Created:"
Write-Host " $htpasswdPath"
Write-Host " $envPath"
Write-Host "Append registry.env values to .env, then copy htpasswd to valhalla:/config/registry/auth/htpasswd."