# Use rocker/r-ver as base image with R pre-installed FROM rocker/r-ver:4.3.2 # Install system dependencies required for R packages RUN apt-get update && apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libssl-dev \ libxml2-dev \ libsodium-dev \ libgit2-dev \ && rm -rf /var/lib/apt/lists/* # Install R packages with explicit error checking RUN R -e "install.packages('plumber', repos='https://cloud.r-project.org/')" && \ R -e "if (!require('plumber')) quit(status=1)" RUN R -e "install.packages(c('readr', 'assertthat', 'jsonlite', 'remotes'), repos='https://cloud.r-project.org/')" # Install httr explicitly with error checking RUN R -e "install.packages('httr', repos='https://cloud.r-project.org/')" && \ R -e "if (!require('httr')) quit(status=1)" # Install dampack from GitHub RUN R -e "remotes::install_github('DARTH-git/dampack', upgrade='never')" && \ R -e "if (!require('dampack')) quit(status=1)" # Verify all packages are installed RUN R -e "stopifnot(require('plumber'), require('readr'), require('assertthat'), require('jsonlite'), require('dampack'), require('httr'))" # Create app directory structure WORKDIR /app RUN mkdir -p /app/api /app/model # Copy API file (model will be fetched from Private GitHub repo at runtime) COPY plumber_hf.R /app/api/plumber.R # Model file fetched from: https://github.com/Veenalim/API_Site2/main/model/darth_funcs.R # COPY darth_funcs.R /app/model/darth_funcs.R # Expose port 7860 (Hugging Face Spaces default) EXPOSE 7860 # Run the Plumber API CMD ["R", "-e", "library(plumber); pr <- plumb('/app/api/plumber.R'); pr$run(host='0.0.0.0', port=7860)"]