102 lines
2.7 KiB
PowerShell
102 lines
2.7 KiB
PowerShell
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
# Load shared utilities
|
|
$utilsPath = Join-Path $PSScriptRoot '..\lib\utils.ps1'
|
|
. $utilsPath
|
|
|
|
.\scripts\Windows\starter.ps1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
# Verify Docker images
|
|
Write-Step "Verifying all images are present..."
|
|
|
|
$config = docker compose config --format json 2>$null | ConvertFrom-Json
|
|
|
|
foreach ($prop in $config.services.PSObject.Properties)
|
|
{
|
|
$svc = $prop.Value
|
|
|
|
if (-not ($svc.PSObject.Properties.Name -contains 'image'))
|
|
{
|
|
continue
|
|
}
|
|
|
|
$image = $svc.PSObject.Properties['image'].Value
|
|
|
|
if (-not (docker image inspect $image 2>$null))
|
|
{
|
|
Write-Error-Custom "Required images not found. Please run install.ps1 first."
|
|
exit 1
|
|
}
|
|
|
|
Write-Info " Found image: $image"
|
|
}
|
|
|
|
# Start services
|
|
Write-Step "Spinning services up..."
|
|
$output = docker compose up --no-build --detach --wait 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error-Custom "Failed to start services"
|
|
Write-Host $output
|
|
exit $LASTEXITCODE
|
|
}
|
|
Write-Success "Services are up and healthy!"
|
|
|
|
# Run pre-run tasks
|
|
Write-Step "Completing pre-run tasks..."
|
|
|
|
Write-Info " Running migrations..."
|
|
$output = docker compose exec -T app uv run manage.py migrate --no-input --verbosity 0 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error-Custom "Migrations failed"
|
|
Write-Host $output
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Info " Initializing..."
|
|
$output = docker compose exec -T app uv run manage.py initialize 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error-Custom "Initialization failed"
|
|
Write-Host $output
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Info " Setting default caches..."
|
|
$output = docker compose exec -T app uv run manage.py set_default_caches 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error-Custom "Cache setup failed"
|
|
Write-Host $output
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Info " Rebuilding search index..."
|
|
$output = docker compose exec -T app uv run manage.py search_index --rebuild -f 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error-Custom "Search index rebuild failed"
|
|
Write-Host $output
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Info " Collecting static files..."
|
|
$output = docker compose exec -T app uv run manage.py collectstatic --clear --no-input --verbosity 0 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error-Custom "Static files collection failed"
|
|
Write-Host $output
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Success "Pre-run tasks completed successfully!"
|
|
|
|
# Cleanup
|
|
Write-Step "Cleaning unused Docker data..."
|
|
docker system prune -f *>$null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Warning-Custom "Docker cleanup had issues, but continuing..."
|
|
}
|
|
Write-Success "Unused Docker data cleaned successfully!"
|
|
|
|
Write-Result ""
|
|
Write-Result "All done! Schon is up and running!"
|