Upload Dockerfile
Browse files- Dockerfile +43 -0
Dockerfile
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use rocker/r-ver as base image with R pre-installed
|
| 2 |
+
FROM rocker/r-ver:4.3.2
|
| 3 |
+
|
| 4 |
+
# Install system dependencies required for R packages
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
libcurl4-openssl-dev \
|
| 7 |
+
libssl-dev \
|
| 8 |
+
libxml2-dev \
|
| 9 |
+
libsodium-dev \
|
| 10 |
+
libgit2-dev \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
# Install R packages with explicit error checking
|
| 14 |
+
RUN R -e "install.packages('plumber', repos='https://cloud.r-project.org/')" && \
|
| 15 |
+
R -e "if (!require('plumber')) quit(status=1)"
|
| 16 |
+
|
| 17 |
+
RUN R -e "install.packages(c('readr', 'assertthat', 'jsonlite', 'remotes'), repos='https://cloud.r-project.org/')"
|
| 18 |
+
|
| 19 |
+
# Install httr explicitly with error checking
|
| 20 |
+
RUN R -e "install.packages('httr', repos='https://cloud.r-project.org/')" && \
|
| 21 |
+
R -e "if (!require('httr')) quit(status=1)"
|
| 22 |
+
|
| 23 |
+
# Install dampack from GitHub
|
| 24 |
+
RUN R -e "remotes::install_github('DARTH-git/dampack', upgrade='never')" && \
|
| 25 |
+
R -e "if (!require('dampack')) quit(status=1)"
|
| 26 |
+
|
| 27 |
+
# Verify all packages are installed
|
| 28 |
+
RUN R -e "stopifnot(require('plumber'), require('readr'), require('assertthat'), require('jsonlite'), require('dampack'), require('httr'))"
|
| 29 |
+
|
| 30 |
+
# Create app directory structure
|
| 31 |
+
WORKDIR /app
|
| 32 |
+
RUN mkdir -p /app/api /app/model
|
| 33 |
+
|
| 34 |
+
# Copy API file (model will be fetched from Private GitHub repo at runtime)
|
| 35 |
+
COPY plumber_hf.R /app/api/plumber.R
|
| 36 |
+
# Model file fetched from: https://github.com/Veenalim/API_Site2/main/model/darth_funcs.R
|
| 37 |
+
# COPY darth_funcs.R /app/model/darth_funcs.R
|
| 38 |
+
|
| 39 |
+
# Expose port 7860 (Hugging Face Spaces default)
|
| 40 |
+
EXPOSE 7860
|
| 41 |
+
|
| 42 |
+
# Run the Plumber API
|
| 43 |
+
CMD ["R", "-e", "library(plumber); pr <- plumb('/app/api/plumber.R'); pr$run(host='0.0.0.0', port=7860)"]
|