# Infra Manager — Windows PowerShell Setup Script $ErrorActionPreference = "Stop" Write-Host "" Write-Host "╔════════════════════════════════════════╗" -ForegroundColor Cyan Write-Host "║ Infra Manager — Setup Script ║" -ForegroundColor Cyan Write-Host "╚════════════════════════════════════════╝" -ForegroundColor Cyan Write-Host "" # Check Docker try { docker --version | Out-Null } catch { Write-Error "Docker not found. Install Docker Desktop first."; exit 1 } Write-Host "[OK] Docker found" -ForegroundColor Green # Copy .env if (-not (Test-Path ".env")) { Copy-Item ".env.example" ".env" Write-Host "[INFO] Created .env from .env.example" -ForegroundColor Cyan } else { Write-Host "[WARN] .env already exists" -ForegroundColor Yellow } # Create SQLite DB New-Item -ItemType Directory -Force -Path "database" | Out-Null if (-not (Test-Path "database\database.sqlite")) { New-Item -ItemType File -Path "database\database.sqlite" | Out-Null Write-Host "[INFO] Created SQLite database" -ForegroundColor Cyan } # Create dirs @("storage\logs", "storage\framework\sessions", "storage\framework\views", "storage\framework\cache", "bootstrap\cache", "public\build", "docker\nginx\ssl") | ForEach-Object { New-Item -ItemType Directory -Force -Path $_ | Out-Null } # Generate self-signed cert (requires OpenSSL in PATH) if (-not (Test-Path "docker\nginx\ssl\cert.pem")) { try { & openssl req -x509 -nodes -days 365 -newkey rsa:2048 ` -keyout "docker\nginx\ssl\key.pem" ` -out "docker\nginx\ssl\cert.pem" ` -subj "/CN=localhost" 2>&1 | Out-Null Write-Host "[OK] SSL certificate generated" -ForegroundColor Green } catch { Write-Host "[WARN] Could not generate SSL cert. HTTPS will not work." -ForegroundColor Yellow } } # Build and start Write-Host "[INFO] Building and starting Docker containers..." -ForegroundColor Cyan docker compose build php docker compose up -d nginx redis Start-Sleep -Seconds 8 # Laravel setup Write-Host "[INFO] Running Laravel setup..." -ForegroundColor Cyan docker compose exec php composer install --optimize-autoloader --no-interaction docker compose exec php php artisan key:generate --force docker compose exec php php artisan migrate --force docker compose exec php php artisan db:seed --force docker compose exec php php artisan storage:link docker compose exec php php artisan config:cache docker compose exec php php artisan route:cache Write-Host "" Write-Host "╔════════════════════════════════════════════════╗" -ForegroundColor Green Write-Host "║ Infra Manager is ready! ║" -ForegroundColor Green Write-Host "║ ║" -ForegroundColor Green Write-Host "║ URL: http://localhost:8080 ║" -ForegroundColor Green Write-Host "║ HTTPS: https://localhost:8443 ║" -ForegroundColor Green Write-Host "║ Email: admin@infra.local ║" -ForegroundColor Green Write-Host "║ Password: Admin@123456 ║" -ForegroundColor Green Write-Host "╚════════════════════════════════════════════════╝" -ForegroundColor Green Write-Host ""