forked from silvertakana/worldwideview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
52 lines (44 loc) · 1.92 KB
/
Copy pathsetup.ps1
File metadata and controls
52 lines (44 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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"