Spaces:
Sleeping
Sleeping
# ------------------------------------------------------------------------------ | |
# 0) Use the R base image | |
# ------------------------------------------------------------------------------ | |
FROM rocker/r-base:latest | |
# Switch to /code as our working directory | |
WORKDIR /code | |
# ------------------------------------------------------------------------------ | |
# 1) Install system dependencies + Miniconda | |
# ------------------------------------------------------------------------------ | |
RUN apt-get update -y && \ | |
apt-get install -y --no-install-recommends \ | |
wget \ | |
bzip2 \ | |
git \ | |
libcurl4-openssl-dev \ | |
libssl-dev \ | |
libxml2-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Miniconda to /opt/conda | |
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh \ | |
&& /bin/bash /tmp/miniconda.sh -b -p /opt/conda \ | |
&& rm /tmp/miniconda.sh \ | |
&& /opt/conda/bin/conda clean -afy | |
# Make sure conda is on PATH | |
ENV PATH=/opt/conda/bin:$PATH | |
# ------------------------------------------------------------------------------ | |
# 2) Install required R packages | |
# ------------------------------------------------------------------------------ | |
RUN install2.r --error \ | |
shiny \ | |
dplyr \ | |
ggplot2 \ | |
readr \ | |
ggExtra \ | |
DT \ | |
parallel \ | |
sandwich \ | |
shinydashboard \ | |
reticulate \ | |
remotes | |
# ------------------------------------------------------------------------------ | |
# 3) Copy your local code (including app.R and data) into the container | |
# ------------------------------------------------------------------------------ | |
COPY . . | |
# ------------------------------------------------------------------------------ | |
# 4) Install strategize from GitHub | |
# ------------------------------------------------------------------------------ | |
RUN Rscript -e "remotes::install_github('cjerzak/strategize-software/strategize')" | |
# ------------------------------------------------------------------------------ | |
# 5) Pre-build the conda environment inside the Docker image by | |
# calling your 'build_backend()' function, which handles the JAX/numpy install. | |
# ------------------------------------------------------------------------------ | |
RUN Rscript -e "library(strategize); strategize::build_backend(conda='auto')" | |
# ------------------------------------------------------------------------------ | |
# 6) Expose the Shiny port (7860) and set the default command to run the Shiny app | |
# ------------------------------------------------------------------------------ | |
EXPOSE 7860 | |
CMD ["R", "--quiet", "-e", "shiny::runApp('/code', host='0.0.0.0', port=7860)"] | |