llauravalente commited on
Commit
ebd628e
·
verified ·
1 Parent(s): 8e2eb61

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -9
Dockerfile CHANGED
@@ -1,14 +1,14 @@
1
  FROM python:3.10-slim
2
 
3
- # 1. Variabili d'ambiente
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
  ENV PYTHONUNBUFFERED=1
7
  ENV GRADIO_SERVER_NAME=0.0.0.0
8
  ENV GRADIO_SERVER_PORT=7860
9
 
10
- # 2. Dipendenze di sistema: R + compilatori + librerie per pacchetti R grafici/web
11
- # Ho aggiunto libfontconfig1 e libfreetype6 per evitare errori con ggplot2
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
  r-base \
14
  r-base-dev \
@@ -25,23 +25,32 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
25
  # 3. Setup cartella di lavoro
26
  WORKDIR /app
27
 
28
- # 4. Installazione pacchetti R (incluso ggplot2 e IRkernel)
 
29
  RUN R -e "install.packages(c('forecast','ggplot2','jsonlite','readr','dplyr','tidyr','stringr','lubridate','broom','IRkernel'), repos='https://cloud.r-project.org')" \
30
  && R -e "IRkernel::installspec(user = FALSE)"
31
 
32
- # 5. Copia del codice e dei notebook
33
  COPY . /app
34
 
35
  # 6. Installazione dipendenze Python
 
36
  RUN pip install --no-cache-dir -r requirements.txt \
37
  && pip install --no-cache-dir notebook ipykernel papermill textblob faker transformers \
38
  && python -m ipykernel install --user --name python3 --display-name "Python 3"
39
 
40
- # 7. Gestione Permessi (Fondamentale per Hugging Face Spaces)
41
- # Crea le cartelle che verranno usate dai notebook e rendile scrivibili
42
- RUN mkdir -p /app/runs /app/artifacts/py/figures /app/artifacts/py/tables /app/artifacts/r/figures /app/artifacts/r/tables \
 
 
 
 
 
43
  && chmod -R 777 /app
44
 
45
- # 8. Esposizione porta e avvio
46
  EXPOSE 7860
 
 
47
  CMD ["python", "app.py"]
 
1
  FROM python:3.10-slim
2
 
3
+ # 1. Variabili d'ambiente per evitare blocchi durante l'installazione
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
  ENV PYTHONUNBUFFERED=1
7
  ENV GRADIO_SERVER_NAME=0.0.0.0
8
  ENV GRADIO_SERVER_PORT=7860
9
 
10
+ # 2. Installazione dipendenze di sistema (R + librerie grafiche e web)
11
+ # Queste sono fondamentali per il rendering di ggplot2 e la comunicazione IRkernel
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
  r-base \
14
  r-base-dev \
 
25
  # 3. Setup cartella di lavoro
26
  WORKDIR /app
27
 
28
+ # 4. Installazione pacchetti R (Inclusi quelli mancanti nello screenshot dell'errore)
29
+ # Risolve l'errore: "there is no package called 'ggplot2'"
30
  RUN R -e "install.packages(c('forecast','ggplot2','jsonlite','readr','dplyr','tidyr','stringr','lubridate','broom','IRkernel'), repos='https://cloud.r-project.org')" \
31
  && R -e "IRkernel::installspec(user = FALSE)"
32
 
33
+ # 5. Copia di tutti i file (app.py, notebook, e i banner PNG)
34
  COPY . /app
35
 
36
  # 6. Installazione dipendenze Python
37
+ # Assicurati che requirements.txt contenga gradio, pandas, papermill
38
  RUN pip install --no-cache-dir -r requirements.txt \
39
  && pip install --no-cache-dir notebook ipykernel papermill textblob faker transformers \
40
  && python -m ipykernel install --user --name python3 --display-name "Python 3"
41
 
42
+ # 7. Risoluzione Build Error: Creazione cartelle e permessi (USER root)
43
+ # Questo risolve il fallimento del job [7/7] visto nei log
44
+ USER root
45
+ RUN mkdir -p runs \
46
+ && mkdir -p artifacts/py/figures \
47
+ && mkdir -p artifacts/py/tables \
48
+ && mkdir -p artifacts/r/figures \
49
+ && mkdir -p artifacts/r/tables \
50
  && chmod -R 777 /app
51
 
52
+ # 8. Esposizione porta per Hugging Face
53
  EXPOSE 7860
54
+
55
+ # 9. Avvio dell'applicazione
56
  CMD ["python", "app.py"]