rinogeek commited on
Commit
f29c658
·
1 Parent(s): 062d102

Initial deploy to Hugging Face

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. app.py +25 -0
Dockerfile CHANGED
@@ -49,4 +49,4 @@ ENV DB_HOST=""
49
  # Hugging Face écoute sur le port 7860
50
  EXPOSE 7860
51
 
52
- CMD ["./start.sh"]
 
49
  # Hugging Face écoute sur le port 7860
50
  EXPOSE 7860
51
 
52
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
+ import time
4
+ import sys
5
+
6
+ def run_command(command, cwd=None):
7
+ print(f"🚀 Exécution : {command}")
8
+ try:
9
+ subprocess.run(command, shell=True, check=True, cwd=cwd)
10
+ except subprocess.CalledProcessError as e:
11
+ print(f"❌ Erreur lors de l'exécution de {command}: {e}")
12
+ sys.exit(1)
13
+
14
+ if __name__ == "__main__":
15
+ print("--- Démarrage de l'initialisation EduConnect ---")
16
+
17
+ # 1. Migrations Django
18
+ run_command("python manage.py migrate --noinput", cwd="/app/backend")
19
+
20
+ # 2. Collecte des fichiers statiques
21
+ run_command("python manage.py collectstatic --noinput", cwd="/app/backend")
22
+
23
+ # 3. Lancement de Supervisor (qui gère Redis, Daphne, Nginx et Celery)
24
+ print("--- Lancement des services via Supervisor ---")
25
+ os.system("supervisord -c /app/supervisord.conf")