FROM rocker/shiny-verse:latest # Install system dependencies including Python RUN apt-get update && apt-get install -y \ python3-full \ python3-pip \ python3-venv \ && rm -rf /var/lib/apt/lists/* WORKDIR /code # Install R packages RUN install2.r --error \ ggExtra \ httr \ jsonlite \ commonmark \ glue \ reticulate # Create and activate virtual environment ENV VIRTUAL_ENV=/opt/venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Install Python packages in the virtual environment RUN pip install --no-cache-dir \ torch \ sentence-transformers \ pandas \ numpy # Create directories for model cache and make them writable RUN mkdir -p /.cache/torch/sentence_transformers \ && chmod -R 777 /.cache # Create additional writable directories that sentence-transformers might need RUN mkdir -p /.cache/huggingface \ && chmod -R 777 /.cache/huggingface # Copy your application files COPY . . # Make the application directory writable for runtime installations RUN chmod -R 777 /code # Enable installation of R packages RUN chmod -R 777 /usr/local/lib/R/site-library # Configure R to use the virtual environment's Python RUN echo "RETICULATE_PYTHON='$VIRTUAL_ENV/bin/python'" >> /usr/local/lib/R/etc/Renviron CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=7860)"]