Add autocomplete status check and restructure test environments
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
This commit is contained in:
@@ -4,7 +4,12 @@
|
||||
# =============================================================================
|
||||
#
|
||||
# Usage :
|
||||
# ./build.sh [OPTIONS]
|
||||
# ./build.sh [--prod | --test-win | --test-linux] [OPTIONS]
|
||||
#
|
||||
# Environnements :
|
||||
# --prod Production (défaut) — docker-compose.yml
|
||||
# --test-win Test Windows (Docker Desktop) — docker-compose.test-win.yml
|
||||
# --test-linux Test Linux — docker-compose.test-linux.yml
|
||||
#
|
||||
# Options :
|
||||
# --help, -h Affiche cette aide
|
||||
@@ -16,17 +21,17 @@
|
||||
#
|
||||
# Étapes exécutées :
|
||||
# 1. Vérifie que Docker et Docker Compose sont installés
|
||||
# 2. Valide le fichier docker-compose.yml
|
||||
# 3. Vérifie que les volumes montés existent sur le host
|
||||
# 2. Valide le fichier docker-compose choisi
|
||||
# 3. Crée les dossiers de test si nécessaire (modes test uniquement)
|
||||
# 4. Construit l'image Docker (multi-stage, ~180MB)
|
||||
# 5. Démarre le conteneur en arrière-plan
|
||||
# 6. Affiche le statut et les logs
|
||||
#
|
||||
# Exemples :
|
||||
# ./build.sh # Build from scratch + démarrage
|
||||
# ./build.sh --cache # Build avec cache + démarrage
|
||||
# ./build.sh --build-only # Build uniquement, sans démarrer
|
||||
# ./build.sh --progress=plain # Sortie verbeuse
|
||||
# ./build.sh # Production
|
||||
# ./build.sh --test-win # Test Windows
|
||||
# ./build.sh --test-linux --cache # Test Linux avec cache
|
||||
# ./build.sh --test-win --build-only # Build test Windows sans démarrer
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
@@ -43,6 +48,8 @@ show_help() {
|
||||
}
|
||||
|
||||
# ----- Parse args -----
|
||||
ENV_MODE="prod"
|
||||
COMPOSE_FILE=""
|
||||
BUILD_ONLY=false
|
||||
USE_CACHE=false
|
||||
BUILD_ARGS=()
|
||||
@@ -52,6 +59,15 @@ for arg in "$@"; do
|
||||
--help|-h)
|
||||
show_help
|
||||
;;
|
||||
--prod)
|
||||
ENV_MODE="prod"
|
||||
;;
|
||||
--test-win)
|
||||
ENV_MODE="test-win"
|
||||
;;
|
||||
--test-linux)
|
||||
ENV_MODE="test-linux"
|
||||
;;
|
||||
--build-only)
|
||||
BUILD_ONLY=true
|
||||
;;
|
||||
@@ -67,6 +83,26 @@ for arg in "$@"; do
|
||||
esac
|
||||
done
|
||||
|
||||
# ----- Select compose file -----
|
||||
case "$ENV_MODE" in
|
||||
prod)
|
||||
COMPOSE_FILE="docker-compose.yml"
|
||||
COMPOSE_ENV_NAME="production"
|
||||
;;
|
||||
test-win)
|
||||
COMPOSE_FILE="docker-compose.test-win.yml"
|
||||
COMPOSE_ENV_NAME="test Windows"
|
||||
;;
|
||||
test-linux)
|
||||
COMPOSE_FILE="docker-compose.test-linux.yml"
|
||||
COMPOSE_ENV_NAME="test Linux"
|
||||
;;
|
||||
*)
|
||||
error "Environnement inconnu : $ENV_MODE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# ----- Pre-flight checks -----
|
||||
if ! command -v docker &>/dev/null; then
|
||||
error "Docker est introuvable. Installez Docker avant de continuer."
|
||||
@@ -87,21 +123,46 @@ fi
|
||||
ok "$($COMPOSE_CMD version --short 2>/dev/null || $COMPOSE_CMD version | head -1)"
|
||||
|
||||
# ----- Validate compose file -----
|
||||
COMPOSE_FILE="docker-compose.yml"
|
||||
if [[ ! -f "$COMPOSE_FILE" ]]; then
|
||||
error "$COMPOSE_FILE introuvable dans $(pwd)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
info "=== ObsiGate — Build & Deploy ==="
|
||||
echo ""
|
||||
info "=== ObsiGate — Build & Deploy ($COMPOSE_ENV_NAME) ==="
|
||||
info "Fichier compose : $COMPOSE_FILE"
|
||||
|
||||
# ----- Extract volume mount paths from compose file and warn about missing ones -----
|
||||
# ----- Test mode: create test directories -----
|
||||
if [[ "$ENV_MODE" == "test-win" ]]; then
|
||||
info "Création des dossiers de test Windows..."
|
||||
mkdir -p /c/dev/git/python/ObsiGate/test_vault
|
||||
mkdir -p /c/dev/git/python/ObsiGate/test_dir
|
||||
# Create a sample note for the test vault
|
||||
if [[ ! -f /c/dev/git/python/ObsiGate/test_vault/Accueil.md ]]; then
|
||||
echo "# Bienvenue dans le vault de test" > /c/dev/git/python/ObsiGate/test_vault/Accueil.md
|
||||
echo "" >> /c/dev/git/python/ObsiGate/test_vault/Accueil.md
|
||||
echo "Ce vault est utilisé pour les tests de développement d'ObsiGate." >> /c/dev/git/python/ObsiGate/test_vault/Accueil.md
|
||||
ok "Note de test créée : test_vault/Accueil.md"
|
||||
fi
|
||||
elif [[ "$ENV_MODE" == "test-linux" ]]; then
|
||||
info "Création des dossiers de test Linux..."
|
||||
mkdir -p /tmp/obsigate-test-vault
|
||||
mkdir -p /tmp/obsigate-test-dir
|
||||
mkdir -p /tmp/obsigate-test-data
|
||||
chmod -R 777 /tmp/obsigate-test-data 2>/dev/null || true
|
||||
if [[ ! -f /tmp/obsigate-test-vault/Accueil.md ]]; then
|
||||
echo "# Bienvenue dans le vault de test" > /tmp/obsigate-test-vault/Accueil.md
|
||||
echo "" >> /tmp/obsigate-test-vault/Accueil.md
|
||||
echo "Ce vault est utilisé pour les tests de développement d'ObsiGate." >> /tmp/obsigate-test-vault/Accueil.md
|
||||
ok "Note de test créée : test-vault/Accueil.md"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ----- Extract volume mount paths and warn about missing ones -----
|
||||
info "Vérification des volumes montés sur le host..."
|
||||
VOLUME_COUNT=0
|
||||
MISSING_COUNT=0
|
||||
while IFS= read -r line; do
|
||||
# Lines like: - /host/path:/container/path
|
||||
if [[ "$line" =~ ^[[:space:]]*-[[:space:]]+(/[^:]+): ]]; then
|
||||
host_path="${BASH_REMATCH[1]}"
|
||||
VOLUME_COUNT=$((VOLUME_COUNT + 1))
|
||||
@@ -115,7 +176,7 @@ while IFS= read -r line; do
|
||||
done < <(grep -E '^\s+-\s+/' "$COMPOSE_FILE")
|
||||
|
||||
if [[ "$VOLUME_COUNT" -eq 0 ]]; then
|
||||
warn "Aucun volume host détecté dans $COMPOSE_FILE. Pensez à configurer vos vaults."
|
||||
warn "Aucun volume host détecté dans $COMPOSE_FILE."
|
||||
fi
|
||||
if [[ "$MISSING_COUNT" -gt 0 ]]; then
|
||||
warn "$MISSING_COUNT volume(s) absent(s). Vérifiez vos chemins dans $COMPOSE_FILE."
|
||||
@@ -132,27 +193,27 @@ else
|
||||
info "Construction de l'image Docker (avec cache)..."
|
||||
fi
|
||||
|
||||
$COMPOSE_CMD build "${BUILD_FLAGS[@]}" "${BUILD_ARGS[@]}"
|
||||
$COMPOSE_CMD -f "$COMPOSE_FILE" build "${BUILD_FLAGS[@]}" "${BUILD_ARGS[@]}"
|
||||
ok "Image construite avec succès"
|
||||
|
||||
# ----- Stop if build-only -----
|
||||
if [[ "$BUILD_ONLY" == true ]]; then
|
||||
echo ""
|
||||
info "Mode build-only : conteneur non démarré."
|
||||
info "Pour démarrer manuellement : $COMPOSE_CMD up -d"
|
||||
info "Pour démarrer manuellement : $COMPOSE_CMD -f $COMPOSE_FILE up -d"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ----- Start the container -----
|
||||
info "Démarrage du conteneur..."
|
||||
$COMPOSE_CMD up -d --remove-orphans
|
||||
$COMPOSE_CMD -f "$COMPOSE_FILE" up -d --remove-orphans
|
||||
ok "Conteneur démarré"
|
||||
|
||||
# ----- Show status -----
|
||||
echo ""
|
||||
info "Statut du conteneur :"
|
||||
$COMPOSE_CMD ps
|
||||
$COMPOSE_CMD -f "$COMPOSE_FILE" ps
|
||||
|
||||
echo ""
|
||||
info "Logs récents (Ctrl+C pour quitter) :"
|
||||
$COMPOSE_CMD logs --tail=20 -f
|
||||
$COMPOSE_CMD -f "$COMPOSE_FILE" logs --tail=20 -f
|
||||
|
||||
Reference in New Issue
Block a user