mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-23 15:08:13 +02:00
Configure application to use a specific port and internal network
Updates Dockerfile and docker-compose.yml to expose port 4523 for the application and ensures it communicates with PostgreSQL over an internal Docker network. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/MNNRXY7
This commit is contained in:
1 parent
1c0e24ece7
commit
9ae2f6b3f2
4 files changed
+223
-15
No files matched your search
+2
-2
@@ -9,9 +9,9 @@ PGHOST=postgres
|
|||||||
DATABASE_URL=postgresql://socialflow:changeme@postgres:5432/socialflow
|
DATABASE_URL=postgresql://socialflow:changeme@postgres:5432/socialflow
|
||||||
|
|
||||||
# Configuration de l'application
|
# Configuration de l'application
|
||||||
PORT=5000
|
PORT=4523
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
APP_URL=http://localhost:5000
|
APP_URL=http://localhost:4523
|
||||||
|
|
||||||
# Clé secrète pour les sessions (CHANGEZ CETTE VALEUR)
|
# Clé secrète pour les sessions (CHANGEZ CETTE VALEUR)
|
||||||
SESSION_SECRET=your-secret-key-change-me-to-random-string
|
SESSION_SECRET=your-secret-key-change-me-to-random-string
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
# Déploiement Docker - Social Flow
|
||||||
|
|
||||||
|
## 📋 Configuration
|
||||||
|
|
||||||
|
L'application utilise Docker Compose pour orchestrer :
|
||||||
|
- **PostgreSQL 16** : Base de données sur réseau interne
|
||||||
|
- **Social Flow App** : Application Node.js exposée sur le port **4523**
|
||||||
|
|
||||||
|
## 🚀 Démarrage rapide
|
||||||
|
|
||||||
|
### 1. Copier le fichier d'environnement
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Éditer les variables d'environnement
|
||||||
|
|
||||||
|
Modifiez `.env` avec vos valeurs :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Base de données
|
||||||
|
PGDATABASE=socialflow
|
||||||
|
PGUSER=socialflow
|
||||||
|
PGPASSWORD=votre_mot_de_passe_securise
|
||||||
|
|
||||||
|
# Application
|
||||||
|
PORT=4523
|
||||||
|
SESSION_SECRET=votre_cle_secrete_aleatoire
|
||||||
|
|
||||||
|
# API OpenRouter (pour la génération IA)
|
||||||
|
OPENROUTER_API_KEY=votre_cle_openrouter
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Lancer les conteneurs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Démarrer en arrière-plan
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Voir les logs
|
||||||
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# Arrêter
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🌐 Accès à l'application
|
||||||
|
|
||||||
|
- **Accès direct** : http://localhost:4523
|
||||||
|
- **Avec Nginx** (reverse proxy) : Voir section ci-dessous
|
||||||
|
|
||||||
|
## 🔧 Architecture réseau
|
||||||
|
|
||||||
|
### Réseau interne (`internal`)
|
||||||
|
- PostgreSQL et l'application communiquent sur ce réseau privé
|
||||||
|
- La base de données n'est **pas exposée** sur l'hôte pour plus de sécurité
|
||||||
|
|
||||||
|
### Réseau nginx (`nginx_default`) - OPTIONNEL
|
||||||
|
- Réseau externe pour le reverse proxy Nginx
|
||||||
|
- **Par défaut : désactivé** (commenté dans docker-compose.yml)
|
||||||
|
- Décommentez-le uniquement si vous utilisez Nginx
|
||||||
|
|
||||||
|
## 📝 Configuration Nginx (optionnelle)
|
||||||
|
|
||||||
|
### Activation du réseau Nginx
|
||||||
|
|
||||||
|
Si vous utilisez Nginx comme reverse proxy :
|
||||||
|
|
||||||
|
1. **Créer le réseau Docker nginx** (une seule fois) :
|
||||||
|
```bash
|
||||||
|
docker network create nginx_default
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Décommenter dans docker-compose.yml** :
|
||||||
|
```yaml
|
||||||
|
# Dans la section app > networks :
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
- nginx_default # ← Décommentez cette ligne
|
||||||
|
|
||||||
|
# Dans la section networks en bas du fichier :
|
||||||
|
networks:
|
||||||
|
# ...
|
||||||
|
nginx_default:
|
||||||
|
external: true # ← Décommentez ces 2 lignes
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Mettre à jour votre configuration Nginx** pour cibler le port **4523** :
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
upstream socialflow {
|
||||||
|
server socialflow-app:4523; # ← Utiliser le port 4523
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name votre-domaine.com;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://socialflow;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Important** : Si vous n'utilisez pas Nginx, vous pouvez retirer le réseau `nginx_default` du `docker-compose.yml`.
|
||||||
|
|
||||||
|
## 🛠️ Commandes utiles
|
||||||
|
|
||||||
|
### Reconstruire les images
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Voir les logs d'un service spécifique
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose logs -f app # Application
|
||||||
|
docker-compose logs -f postgres # Base de données
|
||||||
|
```
|
||||||
|
|
||||||
|
### Accéder au conteneur
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose exec app sh # Shell de l'application
|
||||||
|
docker-compose exec postgres psql -U socialflow # PostgreSQL CLI
|
||||||
|
```
|
||||||
|
|
||||||
|
### Nettoyer complètement
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Arrêter et supprimer les conteneurs, réseaux
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# Supprimer aussi les volumes (⚠️ PERTE DE DONNÉES)
|
||||||
|
docker-compose down -v
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔒 Sécurité en production
|
||||||
|
|
||||||
|
1. **Variables d'environnement** : Ne commitez JAMAIS le fichier `.env`
|
||||||
|
2. **Mots de passe** : Utilisez des mots de passe forts et aléatoires
|
||||||
|
3. **SESSION_SECRET** : Générez une clé aléatoire de 32+ caractères
|
||||||
|
4. **Firewall** : Limitez l'accès au port 4523 ou utilisez Nginx
|
||||||
|
5. **HTTPS** : Configurez un certificat SSL (Let's Encrypt + Nginx)
|
||||||
|
|
||||||
|
## 📊 Healthchecks
|
||||||
|
|
||||||
|
- **PostgreSQL** : Vérifie que la base est prête avant de démarrer l'app
|
||||||
|
- **Migrations** : Exécutées automatiquement au démarrage (`drizzle-kit push --force`)
|
||||||
|
|
||||||
|
## 🐛 Dépannage
|
||||||
|
|
||||||
|
### L'application ne démarre pas
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Vérifier les logs
|
||||||
|
docker-compose logs app
|
||||||
|
|
||||||
|
# Vérifier que PostgreSQL est prêt
|
||||||
|
docker-compose exec postgres pg_isready -U socialflow
|
||||||
|
```
|
||||||
|
|
||||||
|
### Port 4523 déjà utilisé
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Trouver le processus
|
||||||
|
sudo lsof -i :4523
|
||||||
|
|
||||||
|
# Ou changer le port dans .env et docker-compose.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Erreur de connexion à la base de données
|
||||||
|
|
||||||
|
Vérifiez que `DATABASE_URL` dans `.env` correspond aux variables `PGUSER`, `PGPASSWORD`, etc.
|
||||||
|
|
||||||
|
## 📦 Volumes Docker
|
||||||
|
|
||||||
|
- `postgres_data` : Données persistantes de PostgreSQL
|
||||||
|
- Mappages locaux :
|
||||||
|
- `./attached_assets` → `/app/attached_assets` (médias uploadés)
|
||||||
|
- `./migrations` → `/app/migrations` (migrations DB)
|
||||||
|
|
||||||
|
## 🔄 Mise à jour de l'application
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Pull les dernières modifications
|
||||||
|
git pull
|
||||||
|
|
||||||
|
# 2. Reconstruire l'image
|
||||||
|
docker-compose build
|
||||||
|
|
||||||
|
# 3. Redémarrer
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# 4. Vérifier les logs
|
||||||
|
docker-compose logs -f app
|
||||||
|
```
|
||||||
+3
-3
@@ -34,12 +34,12 @@ RUN npm run build
|
|||||||
# Nettoyer les fichiers inutiles pour réduire la taille
|
# Nettoyer les fichiers inutiles pour réduire la taille
|
||||||
RUN rm -rf client node_modules/.cache
|
RUN rm -rf client node_modules/.cache
|
||||||
|
|
||||||
# Exposer le port 5555
|
# Exposer le port de l'application (défini par ENV PORT)
|
||||||
EXPOSE 5555
|
EXPOSE 4523
|
||||||
|
|
||||||
# Variables d'environnement par défaut
|
# Variables d'environnement par défaut
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=5555
|
ENV PORT=4523
|
||||||
|
|
||||||
# Démarrer l'application
|
# Démarrer l'application
|
||||||
CMD ["npm", "run", "start"]
|
CMD ["npm", "run", "start"]
|
||||||
+10
-10
@@ -31,20 +31,19 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: socialflow-app
|
container_name: socialflow-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# Port non exposé publiquement car nginx reverse proxy accède via le réseau Docker
|
ports:
|
||||||
# Décommentez si vous avez besoin d'accéder directement sans nginx :
|
- "4523:4523"
|
||||||
# ports:
|
|
||||||
# - "${PORT:-5555}:5555"
|
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
PORT: 5555
|
PORT: 4523
|
||||||
DATABASE_URL: postgresql://${PGUSER:-socialflow}:${PGPASSWORD:-changeme}@postgres:5432/${PGDATABASE:-socialflow}
|
DATABASE_URL: postgresql://${PGUSER:-socialflow}:${PGPASSWORD:-changeme}@postgres:5432/${PGDATABASE:-socialflow}
|
||||||
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
|
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
|
||||||
SESSION_SECRET: ${SESSION_SECRET:-your-secret-key-change-me}
|
SESSION_SECRET: ${SESSION_SECRET:-your-secret-key-change-me}
|
||||||
APP_URL: ${APP_URL:-http://localhost:5555}
|
APP_URL: ${APP_URL:-http://localhost:4523}
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
- nginx_default
|
# Décommentez la ligne suivante si vous utilisez Nginx reverse proxy :
|
||||||
|
# - nginx_default
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -59,6 +58,7 @@ networks:
|
|||||||
internal:
|
internal:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
# Réseau externe pour nginx reverse proxy
|
# Réseau externe pour nginx reverse proxy (optionnel)
|
||||||
nginx_default:
|
# Décommentez si vous utilisez Nginx :
|
||||||
external: true
|
# nginx_default:
|
||||||
|
# external: true
|
||||||
Reference in new issue
Block a user