diff --git a/.env.production.example b/.env.production.example index 89ddc69..dd77dde 100644 --- a/.env.production.example +++ b/.env.production.example @@ -4,6 +4,7 @@ # Base de données PostgreSQL POSTGRES_PASSWORD=RegisFlow2025!PostgreSQL_CHANGEME POSTGRES_PORT=5433 +DATABASE_URL=postgresql://regisflow:RegisFlow2025!PostgreSQL_CHANGEME@regisflow-db:5432/regisflow?sslmode=disable # Application APP_PORT=5000 diff --git a/Dockerfile.simple b/Dockerfile.simple index e68b42e..bbe8fac 100644 --- a/Dockerfile.simple +++ b/Dockerfile.simple @@ -68,6 +68,11 @@ else fi echo "🌟 Starting RegisFlow application..." +# Assurer que sslmode=disable est présent +if [[ "$DATABASE_URL" != *"sslmode=disable"* ]]; then + export DATABASE_URL="${DATABASE_URL}?sslmode=disable" +fi +echo " Database URL configured with SSL disabled" exec npm start EOF diff --git a/PRODUCTION_UPDATE_2025.md b/PRODUCTION_UPDATE_2025.md index a4273b0..431a5cc 100644 --- a/PRODUCTION_UPDATE_2025.md +++ b/PRODUCTION_UPDATE_2025.md @@ -52,9 +52,16 @@ docker-compose up -d curl http://localhost:5000/health ``` -### Status : ✅ RÉSOLU +### Problème SSL PostgreSQL Résolu -Cette solution garantit un déploiement Docker fiable en production sans les problèmes de fichiers manquants. +4. **Erreur SSL** : "The server does not support SSL connections" + - **Solution** : Configuration SSL désactivée pour Docker local + - **Implémentation** : sslmode=disable dans DATABASE_URL + - **Robustesse** : Détection automatique du mode SSL nécessaire + +### Status : ✅ RÉSOLU COMPLET + +Cette solution garantit un déploiement Docker fiable en production sans les problèmes de fichiers manquants, migrations échouées, ou erreurs SSL. --- diff --git a/attached_assets/Pasted--Attempting-database-migration-rest-express-1-0-0-db-push-drizzle-kit-push-No-conf-1752935500567_1752935500568.txt b/attached_assets/Pasted--Attempting-database-migration-rest-express-1-0-0-db-push-drizzle-kit-push-No-conf-1752935500567_1752935500568.txt new file mode 100644 index 0000000..0fc4125 --- /dev/null +++ b/attached_assets/Pasted--Attempting-database-migration-rest-express-1-0-0-db-push-drizzle-kit-push-No-conf-1752935500567_1752935500568.txt @@ -0,0 +1,120 @@ +🔄 Attempting database migration... + +> rest-express@1.0.0 db:push + +> drizzle-kit push + +No config path provided, using default 'drizzle.config.ts' + +Reading config file '/app/drizzle.config.ts' + +Using 'pg' driver for database querying + +[⣷] Pulling schema from database... + +[⣯] Pulling schema from database... + +[⣟] Pulling schema from database... + +[✓] Pulling schema from database... + +[i] No changes detected + +✅ Migration completed + +🌟 Starting RegisFlow application... + +> rest-express@1.0.0 start + +> NODE_ENV=production node dist/index.js + +/app/node_modules/pg-pool/index.js:45 + + Error.captureStackTrace(err) + + ^ + +Error: The server does not support SSL connections + + at /app/node_modules/pg-pool/index.js:45:11 + + at process.processTicksAndRejections (node:internal/process/task_queues:95:5) + + at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22 + + at async DatabaseStorage.getAllUsers (file:///app/dist/index.js:210:12) + + at async DatabaseStorage.initializeDefaults (file:///app/dist/index.js:384:27) + + at async registerRoutes (file:///app/dist/index.js:636:22) + + at async file:///app/dist/index.js:1277:18 + +Node.js v20.19.4 + +🚀 RegisFlow Production Starting... + +⏳ Waiting for database regisflow-db:5432... + +✅ Database ready + +🔄 Attempting database migration... + +> rest-express@1.0.0 db:push + +> drizzle-kit push + +No config path provided, using default 'drizzle.config.ts' + +Reading config file '/app/drizzle.config.ts' + +Using 'pg' driver for database querying + +[⣷] Pulling schema from database... + +[⣯] Pulling schema from database... + +[⣟] Pulling schema from database... + +[⡿] Pulling schema from database... + +[✓] Pulling schema from database... + +[i] No changes detected + +✅ Migration completed + +🌟 Starting RegisFlow application... + +> rest-express@1.0.0 start + +> NODE_ENV=production node dist/index.js + +/app/node_modules/pg-pool/index.js:45 + + Error.captureStackTrace(err) + + ^ + +Error: The server does not support SSL connections + + at /app/node_modules/pg-pool/index.js:45:11 + + at process.processTicksAndRejections (node:internal/process/task_queues:95:5) + + at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22 + + at async DatabaseStorage.getAllUsers (file:///app/dist/index.js:210:12) + + at async DatabaseStorage.initializeDefaults (file:///app/dist/index.js:384:27) + + at async registerRoutes (file:///app/dist/index.js:636:22) + + at async file:///app/dist/index.js:1277:18 + +Node.js v20.19.4 + + + + + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b91b2e2..b2d7c70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,7 +53,7 @@ services: environment: NODE_ENV: production PORT: 5000 - DATABASE_URL: postgresql://regisflow:${POSTGRES_PASSWORD:-RegisFlow2025!PostgreSQL}@regisflow-db:5432/regisflow + DATABASE_URL: postgresql://regisflow:${POSTGRES_PASSWORD:-RegisFlow2025!PostgreSQL}@regisflow-db:5432/regisflow?sslmode=disable SESSION_SECRET: ${SESSION_SECRET:-RegisFlow2025SessionSecretKey1234567890ABCDEF} TZ: ${TZ:-Europe/Paris} SECURE_COOKIES: ${SECURE_COOKIES:-true} diff --git a/server/db.ts b/server/db.ts index f310051..016adea 100644 --- a/server/db.ts +++ b/server/db.ts @@ -8,9 +8,20 @@ if (!process.env.DATABASE_URL) { ); } -export const pool = new Pool({ +// Configuration de connexion avec SSL désactivé pour Docker local +const connectionConfig = { connectionString: process.env.DATABASE_URL, - ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false -}); + ssl: false // Désactiver SSL pour production Docker locale +}; + +// Si DATABASE_URL contient déjà sslmode=disable, ne pas forcer SSL +if (process.env.DATABASE_URL?.includes('sslmode=disable')) { + connectionConfig.ssl = false; +} else if (process.env.NODE_ENV === 'production' && !process.env.DATABASE_URL?.includes('localhost')) { + // Activer SSL uniquement pour production externe (pas Docker local) + connectionConfig.ssl = { rejectUnauthorized: false }; +} + +export const pool = new Pool(connectionConfig); export const db = drizzle(pool, { schema }); \ No newline at end of file