template4 / Dockerfile
XRachel's picture
Update Dockerfile
02398ef verified
FROM python:3.10-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
# System deps: R + compilers + common R pkg build deps
RUN apt-get update && apt-get install -y --no-install-recommends \
r-base \
r-base-dev \
build-essential \
curl \
git \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
&& rm -rf /var/lib/apt/lists/*
# Install required R packages
RUN R -e "install.packages(c('forecast','ggplot2','jsonlite','readr','dplyr','tidyr','stringr','lubridate','broom'), repos='https://cloud.r-project.org')"
WORKDIR /app
COPY . /app
# Python deps (from requirements.txt)
RUN pip install --no-cache-dir -r requirements.txt
# Notebook execution deps
RUN pip install --no-cache-dir notebook ipykernel papermill
# Pre-install packages that the notebooks install via !pip install
# so papermill doesn't waste time or fail on them at runtime:
# datacreation.ipynb: beautifulsoup4 pandas matplotlib seaborn numpy textblob
# pythonanalysis.ipynb: pandas matplotlib seaborn numpy textblob faker transformers vaderSentiment
# Most are already in requirements.txt; add the extras:
RUN pip install --no-cache-dir textblob faker transformers
# Python kernel (system-wide)
RUN python -m ipykernel install --sys-prefix --name python3 --display-name "Python 3"
# R kernel (system-wide, explicit name)
# RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org/')"
# RUN R -e "IRkernel::installspec(user = FALSE, name = 'ir', displayname = 'R')"
# R packages needed by ranalysis.ipynb
RUN R -e "install.packages( \
c('readr','dplyr','stringr','tidyr','lubridate', \
'ggplot2','forecast','broom','jsonlite'), \
repos='https://cloud.r-project.org')"
# IRkernel for Jupyter / papermill, kernel name 'ir'
RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')"
RUN R -e "IRkernel::installspec(user = FALSE, name = 'ir', displayname = 'R')"
#RUN python -m ipykernel install --user --name python3 --display-name "Python 3"
# R deps for notebook execution via papermill (IRkernel)
RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org/')"
RUN R -e "IRkernel::installspec(user = FALSE)"
EXPOSE 7860
CMD ["python", "app.py"]
RUN jupyter kernelspec list