# Run from the folder where you want to keep your Sydekyks installation. # Compatible with Windows PowerShell 5.1 and PowerShell 7. $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest function Invoke-Docker { & docker @args if ($LASTEXITCODE -ne 0) { throw "Docker command failed (exit $LASTEXITCODE). Fix the error above and run the installer again." } } if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { throw 'Install and start Docker Desktop first: https://docs.docker.com/get-docker/' } Invoke-Docker info | Out-Null $containerOS = Invoke-Docker info --format '{{.OSType}}' if ($containerOS -ne 'linux') { throw 'Switch Docker Desktop to Linux containers, then try again.' } Invoke-Docker compose version | Out-Null $composeHelp = Invoke-Docker compose up --help if (-not ($composeHelp -match '--wait-timeout')) { throw 'Update Docker Compose to a version that supports --wait-timeout.' } $deployment = Join-Path (Get-Location).Path 'sydekyks/deployment' New-Item -ItemType Directory -Force -Path $deployment | Out-Null $temporary = Join-Path $deployment ('.install-' + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $temporary | Out-Null $base = 'https://docs.sydekyks.com/resources/operators' # Windows PowerShell 5.1 may otherwise negotiate older TLS defaults. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 try { $composePath = Join-Path $deployment 'compose.yaml' if (-not (Test-Path -LiteralPath $composePath)) { $download = Join-Path $temporary 'compose.yaml' Invoke-WebRequest -UseBasicParsing -Uri "$base/sydekyks-compose.yaml" -OutFile $download Move-Item -LiteralPath $download -Destination $composePath } $envPath = Join-Path $deployment '.env' if (-not (Test-Path -LiteralPath $envPath)) { $template = Join-Path $temporary 'env.example' Invoke-WebRequest -UseBasicParsing -Uri "$base/sydekyks-env.example.txt" -OutFile $template function New-RandomHex([int] $Length) { $bytes = New-Object byte[] $Length $rng = [Security.Cryptography.RandomNumberGenerator]::Create() try { $rng.GetBytes($bytes) } finally { $rng.Dispose() } return ([BitConverter]::ToString($bytes)).Replace('-', '').ToLowerInvariant() } $configuration = [IO.File]::ReadAllText($template) $configuration = $configuration -replace '(?m)^AP_ENCRYPTION_KEY=\r?$', ('AP_ENCRYPTION_KEY=' + (New-RandomHex 16)) $configuration = $configuration -replace '(?m)^AP_JWT_SECRET=\r?$', ('AP_JWT_SECRET=' + (New-RandomHex 32)) $configuration = $configuration -replace '(?m)^AP_POSTGRES_PASSWORD=\r?$', ('AP_POSTGRES_PASSWORD=' + (New-RandomHex 24)) $generated = Join-Path $temporary '.env' [IO.File]::WriteAllText($generated, $configuration, (New-Object Text.UTF8Encoding $false)) # Keep the configuration readable only by the current Windows user. if ($env:OS -eq 'Windows_NT') { $identity = [Security.Principal.WindowsIdentity]::GetCurrent().Name & icacls $generated /inheritance:r /grant:r "${identity}:(F)" | Out-Null if ($LASTEXITCODE -ne 0) { throw 'Could not protect the environment file.' } } Move-Item -LiteralPath $generated -Destination $envPath Write-Host 'Created private configuration in sydekyks/deployment/.env.' } else { Write-Host 'Reusing your existing configuration and secrets.' } Push-Location (Split-Path $deployment -Parent) try { Invoke-Docker compose --env-file deployment/.env -f deployment/compose.yaml config --quiet Write-Host 'Downloading and starting Sydekyks. The first run can take several minutes.' Invoke-Docker compose --env-file deployment/.env -f deployment/compose.yaml up -d --wait --wait-timeout 300 Invoke-Docker compose --env-file deployment/.env -f deployment/compose.yaml ps } finally { Pop-Location } Write-Host 'Sydekyks is running. Open your configured address (default: http://localhost:8080).' Write-Host 'Create your first account to become the administrator.' Write-Host 'Keep sydekyks/deployment/.env and your Docker volumes for backups and restarts.' } finally { Remove-Item -LiteralPath $temporary -Recurse -Force }