Faffio commited on
Commit
f3ac198
·
1 Parent(s): 2d9f3ba

Add entrypoint script to run Streamlit and FastAPI together

Browse files
Files changed (3) hide show
  1. Dockerfile +9 -2
  2. entrypoint.sh +15 -0
  3. test_scraper.py +0 -8
Dockerfile CHANGED
@@ -38,5 +38,12 @@ WORKDIR $HOME/app
38
 
39
  COPY --chown=user . $HOME/app
40
 
41
- # Cambiamo il comando di avvio
42
- CMD ["uvicorn", "app.api.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
38
 
39
  COPY --chown=user . $HOME/app
40
 
41
+ # Copiamo lo script di avvio e lo rendiamo eseguibile
42
+ COPY --chown=user entrypoint.sh $HOME/app/entrypoint.sh
43
+ RUN chmod +x $HOME/app/entrypoint.sh
44
+
45
+ # Esponiamo la porta 7860 (quella di Streamlit/Hugging Face)
46
+ EXPOSE 7860
47
+
48
+ # Il nuovo comando di avvio è il nostro script
49
+ CMD ["./entrypoint.sh"]
entrypoint.sh ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # 1. Avvia il Backend (FastAPI) in background
4
+ # Usiamo la '&' alla fine per dirgli "non bloccare il terminale, vai in background"
5
+ # Lo facciamo girare sulla porta 8000 interna
6
+ echo "🚀 Starting FastAPI backend..."
7
+ uvicorn app.api.main:app --host 0.0.0.0 --port 8000 &
8
+
9
+ # 2. Aspettiamo qualche secondo che l'API si avvii
10
+ sleep 5
11
+
12
+ # 3. Avvia il Frontend (Streamlit) in primo piano
13
+ # Streamlit DEVE usare la porta 7860 perché è l'unica che Hugging Face espone al pubblico
14
+ echo "🎨 Starting Streamlit frontend..."
15
+ streamlit run streamlit_app/app.py --server.port 7860 --server.address 0.0.0.0
test_scraper.py DELETED
@@ -1,8 +0,0 @@
1
- from app.services.news_client import news_instance
2
-
3
- azienda = "Elettromedia S.P.A."
4
- notizie = news_instance.search_news(azienda, limit=5)
5
-
6
- print(f"\n--- Ultime notizie su {azienda} ---")
7
- for i, testo in enumerate(notizie):
8
- print(f"[{i+1}] {testo}")