-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
80 lines (59 loc) · 1.78 KB
/
Copy pathsetup.ps1
File metadata and controls
80 lines (59 loc) · 1.78 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
$ErrorActionPreference = "Stop"
function Write-Step($text) {
Write-Host ""
Write-Host "==> $text" -ForegroundColor Cyan
}
function Copy-IfMissing($source, $target) {
if (!(Test-Path $target)) {
Copy-Item $source $target
Write-Host "Created $target"
} else {
Write-Host "$target already exists"
}
}
function Wait-Ollama {
Write-Step "Waiting for Ollama..."
while ($true) {
try {
docker exec ollama ollama list *> $null
break
}
catch {
Start-Sleep -Seconds 2
}
}
Write-Host "Ollama is ready."
}
function Ensure-Model($model) {
$installed = docker exec ollama ollama list
if ($installed -match "(?m)^$([regex]::Escape($model))") {
Write-Host "$model already installed."
}
else {
Write-Host "Downloading $model..."
docker exec ollama ollama pull $model
}
}
Write-Step "Checking Docker"
docker version *> $null
Write-Step "Creating .env files"
Copy-IfMissing ".env.example" ".env"
Copy-IfMissing ".env.pgadmin.example" ".env.pgadmin"
Copy-IfMissing ".env.searxng.example" ".env.searxng"
Write-Step "Starting containers"
docker compose up -d --build
Wait-Ollama
Write-Step "Installing Ollama models"
Get-Content "models.txt" |
ForEach-Object { $_.Trim() } |
Where-Object { $_ -and -not $_.StartsWith("#") } |
ForEach-Object {
Ensure-Model $_
}
Write-Step "Running Alembic"
docker compose exec web alembic upgrade head
Write-Host ""
Write-Host "===================================" -ForegroundColor Green
Write-Host "Setup completed successfully!" -ForegroundColor Green
Write-Host "Frontend: http://localhost:8000" -ForegroundColor Green
Write-Host "===================================" -ForegroundColor Green