Add Ollama autocomplete status endpoint to AI routes, update sync panel UI to display autocomplete state, replace monolithic test compose files with separate Linux/Windows variants, and add PowerShell build script for Windows deployment
158 lines
4.7 KiB
PowerShell
158 lines
4.7 KiB
PowerShell
# =============================================================================
|
|
# ObsiGate — Script de build et déploiement Docker (Windows PowerShell)
|
|
# =============================================================================
|
|
#
|
|
# Usage :
|
|
# .\build.ps1 [-Prod | -Test] [OPTIONS]
|
|
#
|
|
# Environnements :
|
|
# -Prod Production (défaut) — docker-compose.yml
|
|
# -Test Test Windows (Docker Desktop) — docker-compose.test-win.yml
|
|
#
|
|
# Options :
|
|
# -BuildOnly Construit l'image sans démarrer le conteneur
|
|
# -NoCache Rebuild complet sans cache Docker (défaut)
|
|
# -UseCache Utilise le cache Docker (plus rapide si peu de changements)
|
|
# -Help Affiche cette aide
|
|
#
|
|
# Exemples :
|
|
# .\build.ps1 # Production
|
|
# .\build.ps1 -Test # Test Windows
|
|
# .\build.ps1 -Test -BuildOnly # Build test sans démarrer
|
|
# .\build.ps1 -Prod -UseCache # Production avec cache
|
|
# =============================================================================
|
|
|
|
param(
|
|
[switch]$Prod,
|
|
[switch]$Test,
|
|
[switch]$BuildOnly,
|
|
[switch]$NoCache,
|
|
[switch]$UseCache,
|
|
[switch]$Help
|
|
)
|
|
|
|
# ----- Helpers -----
|
|
function Write-Info { Write-Host "[INFO] $args" -ForegroundColor Cyan }
|
|
function Write-Ok { Write-Host "[OK] $args" -ForegroundColor Green }
|
|
function Write-Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
|
|
function Write-Error { Write-Host "[ERR] $args" -ForegroundColor Red }
|
|
|
|
# ----- Help -----
|
|
if ($Help) {
|
|
Get-Help $PSCommandPath -Detailed
|
|
exit 0
|
|
}
|
|
|
|
# ----- Select environment -----
|
|
$EnvMode = "prod"
|
|
$ComposeEnvName = "production"
|
|
if ($Test) {
|
|
$EnvMode = "test-win"
|
|
$ComposeEnvName = "test Windows"
|
|
}
|
|
|
|
switch ($EnvMode) {
|
|
"prod" { $ComposeFile = "docker-compose.yml" }
|
|
"test-win" { $ComposeFile = "docker-compose.test-win.yml" }
|
|
}
|
|
|
|
# ----- Pre-flight checks -----
|
|
$dockerVersion = docker --version 2>$null
|
|
if (-not $dockerVersion) {
|
|
Write-Error "Docker est introuvable. Installez Docker Desktop avant de continuer."
|
|
exit 1
|
|
}
|
|
Write-Ok "Docker détecté"
|
|
|
|
$composeVersion = docker compose version 2>$null
|
|
if (-not $composeVersion) {
|
|
Write-Error "Docker Compose est introuvable (plugin docker compose requis)."
|
|
exit 1
|
|
}
|
|
Write-Ok $composeVersion.Trim()
|
|
|
|
# ----- Validate compose file -----
|
|
if (-not (Test-Path $ComposeFile)) {
|
|
Write-Error "$ComposeFile introuvable dans $(Get-Location)"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Info "=== ObsiGate — Build & Deploy ($ComposeEnvName) ==="
|
|
Write-Info "Fichier compose : $ComposeFile"
|
|
|
|
# ----- Test mode: create test directories -----
|
|
if ($EnvMode -eq "test-win") {
|
|
Write-Info "Création des dossiers de test..."
|
|
|
|
$testVault = "C:\dev\git\python\ObsiGate\test_vault"
|
|
$testDir = "C:\dev\git\python\ObsiGate\test_dir"
|
|
|
|
if (-not (Test-Path $testVault)) {
|
|
New-Item -ItemType Directory -Force -Path $testVault | Out-Null
|
|
}
|
|
if (-not (Test-Path $testDir)) {
|
|
New-Item -ItemType Directory -Force -Path $testDir | Out-Null
|
|
}
|
|
|
|
$welcomeFile = Join-Path $testVault "Accueil.md"
|
|
if (-not (Test-Path $welcomeFile)) {
|
|
@"
|
|
# Bienvenue dans le vault de test
|
|
|
|
Ce vault est utilisé pour les tests de développement d'ObsiGate.
|
|
"@ | Out-File -Encoding UTF8 -FilePath $welcomeFile
|
|
Write-Ok "Note de test créée : test_vault\Accueil.md"
|
|
}
|
|
}
|
|
|
|
# ----- Build the image -----
|
|
$BuildArgs = @("-f", $ComposeFile)
|
|
if (-not $UseCache) {
|
|
$BuildArgs += "--no-cache"
|
|
Write-Info "Construction de l'image Docker (sans cache)..."
|
|
} else {
|
|
Write-Info "Construction de l'image Docker (avec cache)..."
|
|
}
|
|
|
|
docker compose @BuildArgs build
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Échec de la construction de l'image Docker."
|
|
exit $LASTEXITCODE
|
|
}
|
|
Write-Ok "Image construite avec succès"
|
|
|
|
# ----- Stop if build-only -----
|
|
if ($BuildOnly) {
|
|
Write-Host ""
|
|
Write-Info "Mode build-only : conteneur non démarré."
|
|
Write-Info "Pour démarrer manuellement : docker compose -f $ComposeFile up -d"
|
|
exit 0
|
|
}
|
|
|
|
# ----- Start the container -----
|
|
Write-Info "Démarrage du conteneur..."
|
|
docker compose -f $ComposeFile up -d --remove-orphans
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Échec du démarrage du conteneur."
|
|
exit $LASTEXITCODE
|
|
}
|
|
Write-Ok "Conteneur démarré"
|
|
|
|
# ----- Show status & tip -----
|
|
Write-Host ""
|
|
Write-Info "Statut du conteneur :"
|
|
docker compose -f $ComposeFile ps
|
|
|
|
Write-Host ""
|
|
Write-Info "Application accessible sur http://localhost:2020"
|
|
if ($EnvMode -eq "prod") {
|
|
Write-Info "Login : admin / (mot de passe dans .env)"
|
|
} else {
|
|
Write-Info "Login : admin / test123"
|
|
}
|
|
Write-Host ""
|
|
|
|
Write-Info "Logs (Ctrl+C pour quitter) :"
|
|
docker compose -f $ComposeFile logs --tail=20 -f
|