mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-21 06:08:18 +02:00
Prepare the application for deployment into a production environment
Configures application for production with enhanced security, performance optimizations, and automated deployment scripts. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 91318273-c764-4fd4-be04-bdc12c38af32 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/6e755801-08e8-4492-805e-ac3610de5a2a.jpg
This commit is contained in:
1 parent
0252abc41c
commit
6f065a4903
9 files changed
+651
-52
No files matched your search
Executable
+141
@@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script de déploiement PRODUCTION RegisFlow
|
||||
# Utilisation: ./deploy-prod.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Déploiement PRODUCTION RegisFlow"
|
||||
echo "===================================="
|
||||
|
||||
# Vérifications préalables
|
||||
echo "🔍 Vérifications préalables..."
|
||||
|
||||
# Vérifier que nous sommes en mode production
|
||||
if [ "$NODE_ENV" != "production" ]; then
|
||||
echo "⚠️ Variable NODE_ENV non définie sur 'production'"
|
||||
read -p "Continuer quand même ? (y/N): " -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Vérifier Docker et Docker Compose
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "❌ Docker n'est pas installé"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
echo "❌ Docker Compose n'est pas installé"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Créer les répertoires de données
|
||||
echo "📁 Création des répertoires de données..."
|
||||
mkdir -p data/{postgres,backups,logs,postgres-logs}
|
||||
chmod 755 data data/*
|
||||
|
||||
# Créer le fichier .env s'il n'existe pas
|
||||
if [ ! -f .env ]; then
|
||||
echo "📝 Création du fichier .env de production..."
|
||||
cp .env.example .env
|
||||
|
||||
echo ""
|
||||
echo "⚠️ CONFIGURATION OBLIGATOIRE POUR LA PRODUCTION :"
|
||||
echo " 1. Éditez le fichier .env"
|
||||
echo " 2. Changez OBLIGATOIREMENT :"
|
||||
echo " - POSTGRES_PASSWORD"
|
||||
echo " - SESSION_SECRET"
|
||||
echo " 3. Pour générer SESSION_SECRET :"
|
||||
echo " openssl rand -base64 32"
|
||||
echo ""
|
||||
read -p "Appuyez sur Entrée après avoir configuré .env..."
|
||||
fi
|
||||
|
||||
# Vérifier les variables critiques
|
||||
echo "🔒 Vérification de la configuration de sécurité..."
|
||||
source .env
|
||||
|
||||
if [ "$POSTGRES_PASSWORD" = "CHANGEZ_MOI_EN_PRODUCTION_2024!" ]; then
|
||||
echo "❌ POSTGRES_PASSWORD doit être changé pour la production !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$SESSION_SECRET" = "CHANGEZ_MOI_GENERER_UNE_CLE_SECRETE_FORTE" ]; then
|
||||
echo "❌ SESSION_SECRET doit être changé pour la production !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Configuration de sécurité validée"
|
||||
|
||||
# Arrêter les services existants
|
||||
echo "🛑 Arrêt des services existants..."
|
||||
docker-compose down 2>/dev/null || true
|
||||
|
||||
# Construire les images
|
||||
echo "🔨 Construction des images de production..."
|
||||
docker-compose build --no-cache
|
||||
|
||||
# Vérifier l'espace disque
|
||||
echo "💾 Vérification de l'espace disque..."
|
||||
DISK_USAGE=$(df / | awk 'NR==2{print $5}' | cut -d'%' -f1)
|
||||
if [ "$DISK_USAGE" -gt 80 ]; then
|
||||
echo "⚠️ Attention: Espace disque faible ($DISK_USAGE%)"
|
||||
read -p "Continuer ? (y/N): " -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Démarrer les services avec configuration production
|
||||
echo "🚀 Démarrage des services de production..."
|
||||
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||
|
||||
# Attendre le démarrage
|
||||
echo "⏳ Attente du démarrage des services..."
|
||||
sleep 30
|
||||
|
||||
# Vérifier la santé des services
|
||||
echo "🏥 Vérification de la santé des services..."
|
||||
for i in {1..30}; do
|
||||
if docker-compose ps | grep -q "healthy"; then
|
||||
echo "✅ Services démarrés avec succès"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 30 ]; then
|
||||
echo "❌ Timeout: Les services ne démarrent pas correctement"
|
||||
echo "📋 Logs des services :"
|
||||
docker-compose logs --tail=20
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Test de connectivité
|
||||
echo "🔗 Test de connectivité..."
|
||||
if curl -f http://localhost:5000/health &>/dev/null; then
|
||||
echo "✅ Application accessible sur http://localhost:5000"
|
||||
else
|
||||
echo "❌ Application non accessible"
|
||||
docker-compose logs regisflow --tail=20
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Afficher le statut final
|
||||
echo ""
|
||||
echo "🎉 DÉPLOIEMENT PRODUCTION RÉUSSI !"
|
||||
echo "=================================="
|
||||
echo "📱 Application RegisFlow : http://localhost:5000"
|
||||
echo "🗄️ PostgreSQL : localhost:5433"
|
||||
echo "📊 Statut des services :"
|
||||
docker-compose ps
|
||||
|
||||
echo ""
|
||||
echo "📋 Commandes utiles :"
|
||||
echo " - Logs : docker-compose logs -f"
|
||||
echo " - Statut : docker-compose ps"
|
||||
echo " - Arrêt : docker-compose down"
|
||||
echo " - Sauvegarde : docker-compose exec regisflow-db pg_dump -U regisflow regisflow > backup.sql"
|
||||
echo ""
|
||||
echo "⚠️ N'oubliez pas de configurer HTTPS avec un reverse proxy pour la production !"
|
||||
Reference in new issue
Block a user