Spaces:
Sleeping
Sleeping
| <# | |
| Helper for Windows PowerShell users: prompts for secrets and starts Docker Compose using a local env file. | |
| Run in PowerShell: `. emplates\start_local.ps1` or `pwsh ./scripts/start_local.ps1` | |
| #> | |
| param() | |
| $root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) | |
| $envFile = Join-Path $root '.env.local' | |
| Write-Host "This helper creates .env.local (gitignored) and starts Docker Compose." -ForegroundColor Cyan | |
| $labelMode = Read-Host "Label mode (hf/openai/mock) [hf]" | |
| if ([string]::IsNullOrWhiteSpace($labelMode)) { $labelMode = 'hf' } | |
| $labelModel = Read-Host "Label model (for hf, e.g. google/flan-t5-large) [google/flan-t5-large]" | |
| if ([string]::IsNullOrWhiteSpace($labelModel)) { $labelModel = 'google/flan-t5-large' } | |
| $hfToken = '' | |
| if ($labelMode -eq 'hf') { | |
| $hfToken = Read-Host -AsSecureString "Enter Hugging Face token" | ConvertFrom-SecureString | |
| # ConvertFrom-SecureString returns encrypted form; for simplicity we convert to plain text below | |
| $hfToken = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((Read-Host -AsSecureString "Enter Hugging Face token (again for conversion)"))) | |
| } | |
| $openaiKey = '' | |
| if ($labelMode -eq 'openai') { | |
| $openaiKey = Read-Host -AsSecureString "Enter OpenAI API key" | ConvertFrom-SecureString | |
| $openaiKey = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((Read-Host -AsSecureString "Enter OpenAI API key (again for conversion)"))) | |
| } | |
| $content = @() | |
| $content += "LABEL_MODE=$labelMode" | |
| $content += "LABEL_MODEL=$labelModel" | |
| $content += "HF_TOKEN=$hfToken" | |
| $content += "OPENAI_API_KEY=$openaiKey" | |
| $content += "MODEL_DIR=/app/storage/models" | |
| $content += "HUGGINGFACE_CACHE=/root/.cache/huggingface" | |
| $content += "DATABASE_URL=postgresql://dark:secret@postgres:5432/darkint" | |
| $content += "REDIS_URL=redis://redis:6379/0" | |
| $content += "SECRET_KEY=change-me" | |
| $content += "MODEL_STORAGE_PATH=./storage/models" | |
| Set-Content -Path $envFile -Value $content -Encoding UTF8 | |
| Write-Host ".env.local created at $envFile" -ForegroundColor Green | |
| Write-Host "Starting Docker services..." -ForegroundColor Cyan | |
| docker compose --env-file $envFile up -d postgres redis backend worker | |
| Write-Host "Tailing worker logs (Ctrl-C to stop)" -ForegroundColor Cyan | |
| docker compose --env-file $envFile logs -f worker | |