Files
worldwideview/self-host/setup.ps1
SilvertakanaandCopilot Autofix powered by AI b11125fd5f refactor(docker): separate self-host Docker compose structure from development (#125)
* refactor(docker): separate self-host Docker compose structure from development

test(ci): add github action to verify self-host scripts

* Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-05-14 14:22:40 +12:00

53 lines
1.9 KiB
PowerShell

Write-Host "[*] Setting up WorldWideView for local self-hosting..."
# Check Docker
try {
$null = docker info 2>&1
if ($LASTEXITCODE -ne 0) { throw }
} catch {
Write-Host "[Error] Docker is not running or not accessible."
Write-Host "Please install or start Docker Desktop: https://docs.docker.com/get-docker/"
exit 1
}
# Check Docker Compose
try {
$null = docker compose version 2>&1
if ($LASTEXITCODE -ne 0) { throw }
} catch {
Write-Host "[Error] Docker Compose is not installed or accessible."
exit 1
}
# Generate docker-compose.yml
Write-Host "[*] Downloading docker-compose.yml..."
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/silvertakana/worldwideview/main/self-host/docker-compose.yml" -OutFile docker-compose.yml
# Generate .env
if (-Not (Test-Path .env)) {
Write-Host "[*] Generating new .env file with AUTH_SECRET..."
$bytes = New-Object Byte[] 32
[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
$secret = -join ($bytes | ForEach-Object { $_.ToString("x2") })
Write-Host "[*] Downloading .env template..."
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/silvertakana/worldwideview/main/.env.example" -OutFile .env
$envContent = Get-Content .env -Raw
$envContent = $envContent -replace "(?m)^AUTH_SECRET=.*", "AUTH_SECRET=$secret"
$envContent | Out-File -FilePath .env -Encoding utf8
} else {
Write-Host "[Success] .env already exists, skipping generation."
}
Write-Host "[*] Pulling latest image updates..."
docker compose pull
Write-Host "[*] Starting Docker container..."
docker compose up -d
Write-Host "`n[Success] WorldWideView is running at http://localhost:3000"
Write-Host " Data is persisted in Docker volume 'wwv-data'"
Write-Host " Auth secret is saved in .env (don't delete this file)`n"
Write-Host "To stop the server: docker compose down"
Write-Host "To view logs: docker compose logs -f wwv"