
- Création du répertoire scripts/ avec tous les scripts d'installation et de test - Scripts d'installation automatique (install.sh, quick-start.sh) - Scripts de maintenance complète (maintenance.sh) - Scripts de test (test-installation.sh, test-api.sh, test-services.sh, test-integration.sh) - Amélioration du Dockerfile avec healthchecks et sécurité - Mise à jour du docker-compose.yml avec healthchecks et dépendances - Makefile étendu avec nouvelles commandes - Documentation complète mise à jour - Fichier de configuration d'exemple (env.example) - app.py corrigé et fonctionnel
165 lines
4.2 KiB
Bash
Executable File
165 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Script de démarrage rapide pour 4NK IA Backend
|
|
# Usage: ./quick-start.sh
|
|
|
|
set -e
|
|
|
|
# Couleurs pour les messages
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Fonction pour afficher les messages
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Vérification rapide des prérequis
|
|
quick_check() {
|
|
log_info "Vérification rapide des prérequis..."
|
|
|
|
if ! command -v docker &> /dev/null; then
|
|
log_error "Docker n'est pas installé"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
|
|
log_error "Docker Compose n'est pas installé"
|
|
exit 1
|
|
fi
|
|
|
|
log_success "Prérequis OK"
|
|
}
|
|
|
|
# Démarrage rapide avec Docker
|
|
quick_start_docker() {
|
|
log_info "Démarrage rapide avec Docker..."
|
|
|
|
# Création du fichier .env minimal s'il n'existe pas
|
|
if [ ! -f .env ]; then
|
|
log_info "Création du fichier .env minimal..."
|
|
cat > .env << EOF
|
|
TZ=Europe/Paris
|
|
POSTGRES_USER=notariat
|
|
POSTGRES_PASSWORD=notariat_pwd
|
|
POSTGRES_DB=notariat
|
|
MINIO_ROOT_USER=minioadmin
|
|
MINIO_ROOT_PASSWORD=minioadmin123
|
|
MINIO_BUCKET=documents
|
|
NEO4J_AUTH=neo4j/neo4j123
|
|
OPENSEARCH_PASSWORD=admin123
|
|
ANYLLM_BASE_URL=http://anythingsqlite:3001
|
|
ANYLLM_API_KEY=your_api_key_here
|
|
OLLAMA_BASE_URL=http://ollama:11434
|
|
EOF
|
|
fi
|
|
|
|
# Démarrage des services essentiels
|
|
log_info "Démarrage des services essentiels..."
|
|
docker-compose -f infra/docker-compose.yml up -d postgres redis minio
|
|
|
|
# Attendre que les services soient prêts
|
|
log_info "Attente du démarrage des services..."
|
|
sleep 15
|
|
|
|
# Démarrage de l'API
|
|
log_info "Démarrage de l'API backend..."
|
|
docker-compose -f infra/docker-compose.yml up -d host-api
|
|
|
|
# Attendre que l'API soit prête
|
|
log_info "Attente du démarrage de l'API..."
|
|
sleep 10
|
|
|
|
log_success "Services démarrés"
|
|
}
|
|
|
|
# Vérification de la santé
|
|
check_health() {
|
|
log_info "Vérification de la santé des services..."
|
|
|
|
# Vérifier l'API
|
|
if curl -f http://localhost:8000/api/health > /dev/null 2>&1; then
|
|
log_success "✅ API backend accessible sur http://localhost:8000"
|
|
else
|
|
log_warning "⚠️ API backend non accessible"
|
|
fi
|
|
|
|
# Vérifier MinIO
|
|
if curl -f http://localhost:9000/minio/health/live > /dev/null 2>&1; then
|
|
log_success "✅ MinIO accessible sur http://localhost:9000"
|
|
else
|
|
log_warning "⚠️ MinIO non accessible"
|
|
fi
|
|
}
|
|
|
|
# Affichage des informations
|
|
show_info() {
|
|
echo ""
|
|
echo "🎉 Démarrage rapide terminé !"
|
|
echo ""
|
|
echo "🌐 Services disponibles:"
|
|
echo " - API Backend: http://localhost:8000"
|
|
echo " - API Documentation: http://localhost:8000/api-docs"
|
|
echo " - MinIO Console: http://localhost:9001"
|
|
echo ""
|
|
echo "🔧 Commandes utiles:"
|
|
echo " - Voir les logs: docker-compose -f infra/docker-compose.yml logs -f"
|
|
echo " - Arrêter: docker-compose -f infra/docker-compose.yml down"
|
|
echo " - Redémarrer: docker-compose -f infra/docker-compose.yml restart"
|
|
echo ""
|
|
echo "📚 Documentation:"
|
|
echo " - README: ./README.md"
|
|
echo " - Installation complète: ./install.sh"
|
|
echo ""
|
|
}
|
|
|
|
# Fonction principale
|
|
main() {
|
|
echo "🚀 Démarrage rapide de 4NK IA Backend"
|
|
echo ""
|
|
|
|
quick_check
|
|
quick_start_docker
|
|
check_health
|
|
show_info
|
|
}
|
|
|
|
# Gestion des arguments
|
|
case "${1:-}" in
|
|
"help"|"-h"|"--help")
|
|
echo "Usage: $0"
|
|
echo ""
|
|
echo "Démarre rapidement les services essentiels de 4NK IA Backend"
|
|
echo ""
|
|
echo "Ce script:"
|
|
echo " - Vérifie les prérequis (Docker, Docker Compose)"
|
|
echo " - Crée un fichier .env minimal si nécessaire"
|
|
echo " - Démarre les services essentiels (PostgreSQL, Redis, MinIO, API)"
|
|
echo " - Vérifie la santé des services"
|
|
echo ""
|
|
echo "Pour une installation complète, utilisez: ./install.sh"
|
|
;;
|
|
"")
|
|
main
|
|
;;
|
|
*)
|
|
log_error "Option invalide: $1"
|
|
echo "Utilisez '$0 help' pour voir l'aide"
|
|
exit 1
|
|
;;
|
|
esac
|