veza/dev-environment/scripts/setup-dev-environment.sh
senke 22e5e21757 chore(audit 2.4, 2.5): supprimer code mort Education et cmd/modern-server
- Supprimer routes/handlers/core Education (backend)
- Supprimer handler MSW education, refs Sidebar/locales
- Basculer Makefile, make/dev.mk, scripts vers cmd/api/main.go
- Supprimer veza-backend-api/cmd/modern-server/
2026-02-15 14:39:40 +01:00

404 lines
12 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 🚀 VEZA DEVELOPMENT ENVIRONMENT SETUP
# Script de configuration complÚte de l'environnement de développement
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}â„č $1${NC}"
}
log_success() {
echo -e "${GREEN}✅ $1${NC}"
}
log_warning() {
echo -e "${YELLOW}⚠ $1${NC}"
}
log_error() {
echo -e "${RED}❌ $1${NC}"
}
# Fonction pour vérifier si une commande existe
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Fonction pour installer une dépendance si elle n'existe pas
install_if_missing() {
local cmd=$1
local install_cmd=$2
if ! command_exists "$cmd"; then
log_warning "$cmd n'est pas installé. Installation..."
eval "$install_cmd"
log_success "$cmd installé avec succÚs"
else
log_success "$cmd est déjà installé"
fi
}
# Header
echo -e "${BLUE}"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ VEZA DEVELOPMENT SETUP ║"
echo "║ Configuration de l'environnement ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
# 1. Vérification des prérequis systÚme
log_info "Vérification des prérequis systÚme..."
# Vérifier le systÚme d'exploitation
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
log_success "SystÚme Linux détecté"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
log_success "SystÚme macOS détecté"
else
log_error "SystÚme d'exploitation non supporté: $OSTYPE"
exit 1
fi
# 2. Installation des dépendances de base
log_info "Installation des dépendances de base..."
# Git
install_if_missing "git" "sudo apt-get update && sudo apt-get install -y git"
# Curl
install_if_missing "curl" "sudo apt-get install -y curl"
# Wget
install_if_missing "wget" "sudo apt-get install -y wget"
# 3. Installation de Docker
log_info "Installation de Docker..."
if ! command_exists "docker"; then
log_warning "Docker n'est pas installé. Installation..."
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
rm get-docker.sh
log_success "Docker installé avec succÚs"
else
log_success "Docker est déjà installé"
fi
# 4. Installation de Docker Compose
log_info "Installation de Docker Compose..."
if ! command_exists "docker-compose"; then
log_warning "Docker Compose n'est pas installé. Installation..."
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
log_success "Docker Compose installé avec succÚs"
else
log_success "Docker Compose est déjà installé"
fi
# 5. Installation de Go
log_info "Installation de Go..."
if ! command_exists "go"; then
log_warning "Go n'est pas installé. Installation..."
GO_VERSION="1.23.0"
wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
rm "go${GO_VERSION}.linux-amd64.tar.gz"
# Ajouter Go au PATH
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
export PATH=$PATH:/usr/local/go/bin
log_success "Go installé avec succÚs"
else
log_success "Go est déjà installé"
fi
# 6. Installation de Rust
log_info "Installation de Rust..."
if ! command_exists "cargo"; then
log_warning "Rust n'est pas installé. Installation..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source ~/.cargo/env
log_success "Rust installé avec succÚs"
else
log_success "Rust est déjà installé"
fi
# 7. Installation de Node.js
log_info "Installation de Node.js..."
if ! command_exists "node"; then
log_warning "Node.js n'est pas installé. Installation..."
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
log_success "Node.js installé avec succÚs"
else
log_success "Node.js est déjà installé"
fi
# 8. Installation de PostgreSQL
log_info "Installation de PostgreSQL..."
if ! command_exists "psql"; then
log_warning "PostgreSQL n'est pas installé. Installation..."
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
log_success "PostgreSQL installé avec succÚs"
else
log_success "PostgreSQL est déjà installé"
fi
# 9. Installation de Redis
log_info "Installation de Redis..."
if ! command_exists "redis-server"; then
log_warning "Redis n'est pas installé. Installation..."
sudo dnf install -y redis-server
sudo systemctl start redis-server
sudo systemctl enable redis-server
log_success "Redis installé avec succÚs"
else
log_success "Redis est déjà installé"
fi
# 10. Installation des outils de développement
log_info "Installation des outils de développement..."
# kubectl
install_if_missing "kubectl" "curl -LO 'https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl' && sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl"
# helm
install_if_missing "helm" "curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash"
# terraform
install_if_missing "terraform" "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg && echo 'deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main' | sudo tee /etc/apt/sources.list.d/hashicorp.list && sudo apt update && sudo apt install terraform"
# 11. Configuration des services
log_info "Configuration des services..."
# Configuration PostgreSQL
sudo -u postgres psql -c "CREATE DATABASE veza_dev;" 2>/dev/null || log_warning "Base de données veza_dev existe déjà"
sudo -u postgres psql -c "CREATE USER veza_user WITH PASSWORD 'veza_password';" 2>/dev/null || log_warning "Utilisateur veza_user existe déjà"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE veza_dev TO veza_user;" 2>/dev/null || log_warning "PrivilÚges déjà accordés"
# Configuration Redis
sudo systemctl restart redis-server
# 12. Création des fichiers de configuration
log_info "Création des fichiers de configuration..."
# Fichier .env pour le développement
cat > .env.dev << 'ENVEOF'
# Configuration de développement Veza
NODE_ENV=development
DEBUG=true
# Base de données
DB_HOST=localhost
DB_PORT=5432
DB_NAME=veza_dev
DB_USER=veza_user
DB_PASSWORD=veza_password
DB_SSL_MODE=disable
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Services
BACKEND_PORT=8080
CHAT_PORT=3001
STREAM_PORT=8000
FRONTEND_PORT=3000
# JWT
JWT_SECRET=dev_jwt_secret_key_change_in_production
JWT_EXPIRES_IN=24h
# OAuth (pour le développement)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
# Monitoring
PROMETHEUS_PORT=9090
GRAFANA_PORT=3001
JAEGER_PORT=16686
ENVEOF
log_success "Fichier .env.dev créé"
# 13. Installation des dépendances des projets
log_info "Installation des dépendances des projets..."
# Backend API
if [ -d "veza-backend-api" ]; then
log_info "Installation des dépendances Backend API..."
cd veza-backend-api
go mod download
go mod tidy
cd ..
log_success "Dépendances Backend API installées"
fi
# Chat Server
if [ -d "veza-chat-server" ]; then
log_info "Installation des dépendances Chat Server..."
cd veza-chat-server
cargo build
cd ..
log_success "Dépendances Chat Server installées"
fi
# Stream Server
if [ -d "veza-stream-server" ]; then
log_info "Installation des dépendances Stream Server..."
cd veza-stream-server
cargo build
cd ..
log_success "Dépendances Stream Server installées"
fi
# Frontend
if [ -d "veza-frontend" ]; then
log_info "Installation des dépendances Frontend..."
cd veza-frontend
npm install
cd ..
log_success "Dépendances Frontend installées"
fi
# Mobile
if [ -d "veza-mobile" ]; then
log_info "Installation des dépendances Mobile..."
cd veza-mobile
npm install
cd ..
log_success "Dépendances Mobile installées"
fi
# 14. Création des scripts utiles
log_info "Création des scripts utiles..."
# Script de démarrage de tous les services
cat > start-all-services.sh << 'SCRIPTEOF'
#!/bin/bash
# Script de démarrage de tous les services Veza
echo "🚀 DĂ©marrage de tous les services Veza..."
# Démarrer PostgreSQL
sudo systemctl start postgresql
echo "✅ PostgreSQL dĂ©marrĂ©"
# Démarrer Redis
sudo systemctl start redis-server
echo "✅ Redis dĂ©marrĂ©"
# Démarrer Backend API
cd veza-backend-api
go run cmd/api/main.go &
BACKEND_PID=$!
echo "✅ Backend API dĂ©marrĂ© (PID: $BACKEND_PID)"
# Démarrer Chat Server
cd ../veza-chat-server
cargo run &
CHAT_PID=$!
echo "✅ Chat Server dĂ©marrĂ© (PID: $CHAT_PID)"
# Démarrer Stream Server
cd ../veza-stream-server
cargo run &
STREAM_PID=$!
echo "✅ Stream Server dĂ©marrĂ© (PID: $STREAM_PID)"
# Démarrer Frontend
cd ../veza-frontend
npm run dev &
FRONTEND_PID=$!
echo "✅ Frontend dĂ©marrĂ© (PID: $FRONTEND_PID)"
echo "🎉 Tous les services sont dĂ©marrĂ©s!"
echo "Backend API: http://localhost:8080"
echo "Chat Server: http://localhost:3001"
echo "Stream Server: http://localhost:8000"
echo "Frontend: http://localhost:3000"
# Sauvegarder les PIDs
echo $BACKEND_PID > logs/backend.pid
echo $CHAT_PID > logs/chat-server.pid
echo $STREAM_PID > logs/stream-server.pid
echo $FRONTEND_PID > logs/frontend.pid
SCRIPTEOF
chmod +x start-all-services.sh
log_success "Script start-all-services.sh créé"
# Script d'arrĂȘt de tous les services
cat > stop-all-services.sh << 'SCRIPTEOF'
#!/bin/bash
# Script d'arrĂȘt de tous les services Veza
echo "🛑 ArrĂȘt de tous les services Veza..."
# ArrĂȘter les services via leurs PIDs
if [ -f "logs/backend.pid" ]; then
kill $(cat logs/backend.pid) 2>/dev/null || true
echo "✅ Backend API arrĂȘtĂ©"
fi
if [ -f "logs/chat-server.pid" ]; then
kill $(cat logs/chat-server.pid) 2>/dev/null || true
echo "✅ Chat Server arrĂȘtĂ©"
fi
if [ -f "logs/stream-server.pid" ]; then
kill $(cat logs/stream-server.pid) 2>/dev/null || true
echo "✅ Stream Server arrĂȘtĂ©"
fi
if [ -f "logs/frontend.pid" ]; then
kill $(cat logs/frontend.pid) 2>/dev/null || true
echo "✅ Frontend arrĂȘtĂ©"
fi
echo "🎉 Tous les services sont arrĂȘtĂ©s!"
SCRIPTEOF
chmod +x stop-all-services.sh
log_success "Script stop-all-services.sh créé"
# 15. Création du répertoire logs
mkdir -p logs
log_success "Répertoire logs créé"
# 16. Finalisation
log_success "Configuration de l'environnement terminée!"
echo -e "${GREEN}"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ SETUP TERMINÉ AVEC SUCCÈS ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
echo -e "${BLUE}📋 Prochaines Ă©tapes:${NC}"
echo "1. Redémarrez votre terminal ou exécutez: source ~/.bashrc"
echo "2. Exécutez: ./start-all-services.sh pour démarrer tous les services"
echo "3. Visitez http://localhost:3000 pour accéder au frontend"
echo "4. Consultez DEVELOPMENT_STRATEGY.md pour la stratégie de développement"
echo -e "${YELLOW}⚠ Note: Vous devrez peut-ĂȘtre redĂ©marrer votre session pour que tous les PATH soient mis Ă  jour.${NC}"