Repository navigation
Expand file tree
/
Copy pathdocker-compose.ps1
More file actions
52 lines (42 loc) · 2 KB
/
Copy pathdocker-compose.ps1
File metadata and controls
52 lines (42 loc) · 2 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
#Requires -Version 5.0
$DockerComposeFile = "docker-compose.yml"
$BackendCheckAttempts = 60
$BackendCheckDelaySeconds = 10
function Wait-ForBackend {
for ($i = 1; $i -le $BackendCheckAttempts; $i++) {
& docker compose -f $DockerComposeFile exec -T backend curl --fail --silent http://localhost:8000/api/health/ *> $null
if ($LASTEXITCODE -eq 0) {
Write-Host "Backend is ready!" -ForegroundColor Green
return
}
if ($i -eq $BackendCheckAttempts) {
$timeoutSeconds = $BackendCheckAttempts * $BackendCheckDelaySeconds
Write-Host "Backend did not become ready within ${timeoutSeconds}s. Recent backend logs:" -ForegroundColor Red
docker compose -f $DockerComposeFile logs --tail=50 backend
exit 1
}
Start-Sleep -Seconds $BackendCheckDelaySeconds
}
}
if (-not (Test-Path -Path $DockerComposeFile -PathType Leaf)) {
Write-Host "Compose file not found: $DockerComposeFile" -ForegroundColor Red
exit 1
}
# Check if database file exists
if (Test-Path "db/ciso-assistant.sqlite3") {
Write-Host "The database seems already created. You should launch 'docker compose up -d' instead." -ForegroundColor Yellow
Write-Host "For a clean start, you can remove the db folder, and then run 'docker compose rm -fs' and start over" -ForegroundColor Yellow
exit 1
}
Write-Host "Starting CISO Assistant services..." -ForegroundColor Cyan
docker compose -f $DockerComposeFile pull
Write-Host ""
Write-Host "Waiting for CISO Assistant backend to be ready, please wait..." -ForegroundColor Cyan
docker compose -f $DockerComposeFile up -d
Wait-ForBackend
Write-Host ""
Write-Host "Creating superuser..." -ForegroundColor Cyan
docker compose -f $DockerComposeFile exec backend python manage.py createsuperuser
Write-Host ""
Write-Host "Initialization complete!" -ForegroundColor Green
Write-Host "You can now access CISO Assistant at https://localhost:8443 (or the host:port you've specified)" -ForegroundColor Green