Fix Docker entrypoint and apply database migrations for production

Update Dockerfile to correctly copy and execute the entrypoint script, revert CMD to node dist/index.js, and update the SOLUTION_IMMEDIATE.md and add fix-docker-entrypoint.sh to address the 'exec /app/scripts/docker-entrypoint.sh: no such file or directory' error by manually applying database migrations for DLC products.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: f9197b9b-a5b3-4469-a27d-930a9e9ee736
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/f9197b9b-a5b3-4469-a27d-930a9e9ee736/i2gFnxm
This commit is contained in:
michaelschal committed 2025-08-18 09:42:19 +00:00
1 parent a2554c4962
commit f279774f04
3 files changed
+80 -59

No files matched your search

+5 -3
View File
@@ -84,6 +84,7 @@ COPY --from=build --chown=nextjs:nodejs /app/shared ./shared
# Copy migration scripts and files
COPY --chown=nextjs:nodejs scripts/ ./scripts/
COPY --chown=nextjs:nodejs migrations/ ./migrations/
COPY --chown=nextjs:nodejs scripts/docker-entrypoint.sh ./scripts/docker-entrypoint.sh
# Create symlink for public files to be accessible from dist
RUN ln -sf /app/dist/public /app/dist/public
@@ -109,8 +110,9 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
# Make scripts executable
RUN chmod +x /app/scripts/auto-migrate-production.sh && \
chmod +x /app/scripts/docker-entrypoint.sh
chmod +x /app/scripts/docker-entrypoint.sh && \
ls -la /app/scripts/ && \
test -f /app/scripts/docker-entrypoint.sh || echo "ERREUR: docker-entrypoint.sh manquant"
# Use entrypoint script for automatic migrations
ENTRYPOINT ["/app/scripts/docker-entrypoint.sh"]
# Start application normally (migration applied separately)
CMD ["node", "dist/index.js"]
+35 -56
View File
@@ -1,78 +1,57 @@
# 🚨 SOLUTION IMMÉDIATE POUR LA PRODUCTION
## 🎯 Objectif
Créer **UNIQUEMENT** la table `announcements` manquante. Toutes les autres tables existent déjà en production et ne doivent pas être touchées.
# SOLUTION IMMÉDIATE - Migration DLC Production
## Problème
La table `announcements` n'existe pas dans votre base de données de production, ce qui cause l'erreur:
```
Error: relation "announcements" does not exist
exec /app/scripts/docker-entrypoint.sh: no such file or directory
```
## Solution en 3 étapes simples
## Solution Rapide (2 minutes)
### 1. Connectez-vous à votre serveur de production
### ÉTAPE 1: Appliquer la migration directement
```bash
# SSH vers votre serveur
ssh votre-serveur-production
```
# Sur votre serveur de production, exécutez :
docker-compose exec logiflow-db psql -U logiflow_admin -d logiflow_db -c "
ALTER TABLE dlc_products
ADD COLUMN IF NOT EXISTS stock_epuise boolean DEFAULT false NOT NULL,
ADD COLUMN IF NOT EXISTS stock_epuise_by varchar(255),
ADD COLUMN IF NOT EXISTS stock_epuise_at timestamp;
### 2. Accédez au conteneur Docker
```bash
# Entrer dans le conteneur
docker exec -it logiflow-logiflow-1 bash
```
### 3. Créer la table directement
```bash
# Dans le conteneur, exécuter cette commande :
psql $DATABASE_URL -c "
CREATE TABLE IF NOT EXISTS announcements (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal',
author_id VARCHAR(255) NOT NULL,
group_id INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
CONSTRAINT announcements_priority_check CHECK (priority IN ('normal', 'important', 'urgent')),
CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_announcements_priority ON announcements(priority);
CREATE INDEX IF NOT EXISTS idx_announcements_created_at ON announcements(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_announcements_author_id ON announcements(author_id);
CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id);
CREATE INDEX IF NOT EXISTS idx_dlc_products_stock_epuise ON dlc_products(stock_epuise);
"
```
### 4. Vérifier que ça fonctionne
### ÉTAPE 2: Redémarrer l'application
```bash
# Vérifier que la table existe
psql $DATABASE_URL -c "SELECT 'SUCCESS: Table announcements créée!' as status;"
docker-compose restart logiflow
```
### 5. Sortir du conteneur
## Alternative avec script automatique
```bash
exit
# Utilisez le script de correction :
chmod +x fix-docker-entrypoint.sh
./fix-docker-entrypoint.sh
```
## Résultat attendu
Après ces étapes, le système d'annonces fonctionnera immédiatement sur votre production.
## Alternative plus simple (une seule commande)
## Vérification
```bash
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "CREATE TABLE IF NOT EXISTS announcements (id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, content TEXT NOT NULL, priority VARCHAR(20) NOT NULL DEFAULT 'normal', author_id VARCHAR(255) NOT NULL, group_id INTEGER, created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), CONSTRAINT announcements_priority_check CHECK (priority IN ('normal', 'important', 'urgent')), CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE, CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE);"
# Vérifier que les colonnes existent :
docker-compose exec logiflow-db psql -U logiflow_admin -d logiflow_db -c "
SELECT column_name FROM information_schema.columns
WHERE table_name='dlc_products'
AND column_name LIKE '%stock_epuise%';
"
```
## Script minimal (nouvelle option)
```bash
# Copier et exécuter le script minimal
docker cp scripts/fix-announcements-only.sh logiflow-logiflow-1:/app/scripts/
docker exec logiflow-logiflow-1 chmod +x /app/scripts/fix-announcements-only.sh
docker exec logiflow-logiflow-1 /app/scripts/fix-announcements-only.sh
Résultat attendu :
```
column_name
-----------------
stock_epuise
stock_epuise_by
stock_epuise_at
```
La correction du problème `Select.Item` value est déjà faite dans le code source.
## Après cette correction
- ✅ L'erreur "column does not exist" disparaîtra
- ✅ L'interface DLC fonctionnera
- ✅ Les boutons stock épuisé seront opérationnels
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Script de correction pour Docker entrypoint
# Applique la migration directement via docker-compose exec
set -e
echo "🔧 [FIX] Correction du problème docker-entrypoint.sh"
# Vérifier que le conteneur fonctionne
if ! docker-compose ps | grep -q logiflow; then
echo "❌ [FIX] Conteneur logiflow non trouvé, démarrage..."
docker-compose up -d logiflow-db
sleep 10
fi
echo "🔄 [FIX] Application de la migration DLC directement..."
# Appliquer la migration via exec
docker-compose exec -T logiflow-db psql -U logiflow_admin -d logiflow_db << 'EOF'
-- Migration DLC stock épuisé
ALTER TABLE dlc_products
ADD COLUMN IF NOT EXISTS stock_epuise boolean DEFAULT false NOT NULL,
ADD COLUMN IF NOT EXISTS stock_epuise_by varchar(255),
ADD COLUMN IF NOT EXISTS stock_epuise_at timestamp;
-- Index pour performance
CREATE INDEX IF NOT EXISTS idx_dlc_products_stock_epuise ON dlc_products(stock_epuise);
-- Vérification
SELECT 'Migration DLC appliquée' as status;
EOF
echo "✅ [FIX] Migration DLC appliquée avec succès"
# Redémarrer le conteneur application
echo "🔄 [FIX] Redémarrage du conteneur application..."
docker-compose restart logiflow
echo "✅ [FIX] Correction terminée"