Spaces:
Build error
Build error
Update Dockerfile
Browse files- 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.
|
| 11 |
-
#
|
| 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 (
|
|
|
|
| 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
|
| 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.
|
| 41 |
-
#
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
&& chmod -R 777 /app
|
| 44 |
|
| 45 |
-
# 8. Esposizione porta
|
| 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"]
|