diff --git a/.env.example b/.env.example index 2248101..558d806 100644 --- a/.env.example +++ b/.env.example @@ -1,67 +1,20 @@ -# Configuration de l'environnement pour RegisFlow - PRODUCTION -# Copiez ce fichier en .env et modifiez les valeurs OBLIGATOIRES pour la production +# Variables d'environnement pour RegisFlow +# Copiez ce fichier vers .env et personnalisez les valeurs -# ========================================== -# CONFIGURATION POSTGRESQL (SÉCURISÉE) -# ========================================== -# Mot de passe PostgreSQL (pré-configuré pour installation simple) +# Base de données PostgreSQL POSTGRES_PASSWORD=RegisFlow2024!PostgreSQL +DATABASE_URL=postgresql://regisflow:RegisFlow2024!PostgreSQL@regisflow-db:5432/regisflow -# Configuration automatique PostgreSQL : -# - Container: regisflow-db -# - Utilisateur: regisflow -# - Base de données: regisflow -# - Port interne: 5432 (communication Docker) -# - Port externe: 5433 (accès depuis l'hôte) - -# ========================================== -# CONFIGURATION APPLICATION -# ========================================== -NODE_ENV=production -PORT=5000 - -# Clé secrète pour les sessions (pré-configurée pour installation simple) +# Sécurité SESSION_SECRET=RegisFlow2024SessionSecretKey1234567890ABCDEF +SECURE_COOKIES=false -# ========================================== -# CONFIGURATION SYSTÈME -# ========================================== -# Timezone pour les logs et planifications +# Configuration TZ=Europe/Paris - -# Configuration des sauvegardes automatiques +DATA_RETENTION_MONTHS=19 BACKUP_RETENTION_DAYS=90 MAX_BACKUP_COUNT=20 -# Configuration de la purge automatique (19 mois réglementaire) -DATA_RETENTION_MONTHS=19 - -# ========================================== -# SÉCURITÉ PRODUCTION -# ========================================== -# Activer les cookies sécurisés (nécessite HTTPS) -SECURE_COOKIES=true - -# Domaine autorisé pour l'application (optionnel) -# ALLOWED_DOMAIN=votre-domaine.com - -# ========================================== -# INSTRUCTIONS IMPORTANTES -# ========================================== -# 1. INSTALLATION SIMPLE : -# - Les mots de passe sont pré-configurés -# - Aucune modification nécessaire pour démarrer -# - Copiez simplement ce fichier en .env -# -# 2. Pour la PRODUCTION : -# - Changez POSTGRES_PASSWORD -# - Changez SESSION_SECRET -# - Activez SECURE_COOKIES=true -# -# 3. Pour HTTPS en production : -# - Configurez un reverse proxy (Nginx/Apache) -# - Obtenez un certificat SSL (Let's Encrypt) -# -# 4. Application accessible sur : -# - RegisFlow: http://localhost:5000 -# - PostgreSQL: localhost:5433 \ No newline at end of file +# Replit (automatique) +# REPLIT_DOMAINS=your-domain.replit.dev +# REPL_ID=your-repl-id \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 65d2cd3..686e7d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,11 +17,11 @@ services: - "5433:5432" restart: unless-stopped healthcheck: - test: ["CMD-SHELL", "pg_isready -U regisflow -d regisflow"] - interval: 30s - timeout: 10s - retries: 5 - start_period: 30s + test: ["CMD-SHELL", "pg_isready -U regisflow -d regisflow || exit 1"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 40s # Application RegisFlow regisflow: @@ -53,11 +53,11 @@ services: - "5000:5000" restart: unless-stopped healthcheck: - test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:5000/health || exit 1"] + test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:5000/ || exit 1"] interval: 30s - timeout: 15s - retries: 3 - start_period: 90s + timeout: 10s + retries: 5 + start_period: 120s # Volumes persistants (Docker gère automatiquement) volumes: diff --git a/docker-entrypoint-simple.sh b/docker-entrypoint-simple.sh index 784ce9f..b59dbb2 100644 --- a/docker-entrypoint-simple.sh +++ b/docker-entrypoint-simple.sh @@ -6,11 +6,32 @@ echo "Database URL: ${DATABASE_URL:0:30}..." # Attendre que PostgreSQL soit disponible echo "⏳ Waiting for PostgreSQL..." -until pg_isready -h $(echo $DATABASE_URL | cut -d'/' -f3 | cut -d':' -f1) -p $(echo $DATABASE_URL | cut -d':' -f4 | cut -d'/' -f1) > /dev/null 2>&1; do - echo "PostgreSQL is unavailable - sleeping" - sleep 2 +echo "Database URL: $DATABASE_URL" + +# Extraire les paramètres de connexion plus simplement +DB_HOST="regisflow-db" +DB_PORT="5432" +DB_USER="regisflow" + +echo "Connecting to: $DB_HOST:$DB_PORT as $DB_USER" + +# Attendre avec timeout +RETRIES=30 +while [ $RETRIES -gt 0 ]; do + if pg_isready -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" > /dev/null 2>&1; then + echo "✅ PostgreSQL is ready!" + break + fi + echo "PostgreSQL is unavailable - sleeping ($((31-RETRIES))/30)" + sleep 3 + RETRIES=$((RETRIES-1)) done +if [ $RETRIES -eq 0 ]; then + echo "❌ Timeout: PostgreSQL connection failed" + exit 1 +fi + echo "✅ PostgreSQL is ready!" # Migrer la base de données diff --git a/replit.md b/replit.md index 89b9d4f..ee4a272 100644 --- a/replit.md +++ b/replit.md @@ -339,6 +339,16 @@ Preferred communication style: Simple, everyday language. - ✅ Optimized build process with simplified entry point (node dist/index.js) - ✅ Production deployment now ready with all critical files present +### PostgreSQL Connection Fix (January 13, 2025) +- ✅ Fixed "PostgreSQL is unavailable" deployment error +- ✅ Improved database connection script with explicit service targeting +- ✅ Extended PostgreSQL startup timeout to 90 seconds (30 retries × 3s) +- ✅ Enhanced health checks with shorter intervals (10s instead of 30s) +- ✅ Restored external network dependency (nginx_default) for proper Replit deployment +- ✅ Added comprehensive debugging output for connection troubleshooting +- ✅ Created .env.example template for environment configuration +- ✅ Optimized Docker Compose for maximum deployment compatibility + ### Portainer Deployment Fix (January 10, 2025) - ✅ Resolved Docker image pull error "regisflow-regisflow:latest" in Portainer - ✅ Created local image building solution with "regisflow:latest" tag