llauravalente commited on
Commit
da9e737
·
verified ·
1 Parent(s): a0cfa13

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -22
Dockerfile CHANGED
@@ -1,13 +1,14 @@
1
  FROM python:3.10-slim
2
 
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV PYTHONDONTWRITEBYTECODE=1
5
  ENV PYTHONUNBUFFERED=1
6
-
7
  ENV GRADIO_SERVER_NAME=0.0.0.0
8
  ENV GRADIO_SERVER_PORT=7860
9
 
10
- # System deps: R + compilers + common R pkg build deps
 
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  r-base \
13
  r-base-dev \
@@ -17,33 +18,30 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
17
  libcurl4-openssl-dev \
18
  libssl-dev \
19
  libxml2-dev \
 
 
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
- # Install required R packages
23
- RUN R -e "install.packages(c('forecast','ggplot2','jsonlite','readr','dplyr','tidyr','stringr','lubridate','broom'), repos='https://cloud.r-project.org')"
24
-
25
  WORKDIR /app
26
- COPY . /app
27
 
28
- # Python deps (from requirements.txt)
29
- RUN pip install --no-cache-dir -r requirements.txt
 
30
 
31
- # Notebook execution deps
32
- RUN pip install --no-cache-dir notebook ipykernel papermill
33
-
34
- # Pre-install packages that the notebooks install via !pip install
35
- # so papermill doesn't waste time or fail on them at runtime:
36
- # datacreation.ipynb: beautifulsoup4 pandas matplotlib seaborn numpy textblob
37
- # pythonanalysis.ipynb: pandas matplotlib seaborn numpy textblob faker transformers vaderSentiment
38
- # Most are already in requirements.txt; add the extras:
39
- RUN pip install --no-cache-dir textblob faker transformers
40
 
41
- RUN python -m ipykernel install --user --name python3 --display-name "Python 3"
 
 
 
42
 
43
- # R deps for notebook execution via papermill (IRkernel)
44
- RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org/')"
45
- RUN R -e "IRkernel::installspec(user = FALSE)"
 
46
 
 
47
  EXPOSE 7860
48
-
49
  CMD ["python", "app.py"]
 
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 \
 
18
  libcurl4-openssl-dev \
19
  libssl-dev \
20
  libxml2-dev \
21
+ libfontconfig1-dev \
22
+ libfreetype6-dev \
23
  && rm -rf /var/lib/apt/lists/*
24
 
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"]