fastrerandomize / Dockerfile
cjerzak's picture
Update Dockerfile
f67f49a verified
# ------------------------------------------------------------------------------
# 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 \
&& 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
# (We add reticulate + a few extras such as DT and shinydashboard
# since your app uses them.)
# ------------------------------------------------------------------------------
RUN install2.r --error \
shiny \
dplyr \
ggplot2 \
readr \
ggExtra \
DT \
parallel \
shinydashboard \
reticulate \
remotes
# ------------------------------------------------------------------------------
# 3) Copy your local code (including app.R and CODEBASE) into the container
# ------------------------------------------------------------------------------
COPY . .
# If your fastrerandomize package is on GitHub and not installed yet,
# uncomment and adjust the GitHub URL as appropriate:
RUN Rscript -e "remotes::install_github('cjerzak/fastrerandomize-software/fastrerandomize')"
# ------------------------------------------------------------------------------
# 4) (Optional) Pre-build the conda environment inside the Docker image
# by calling your 'build_backend()' function.
# This ensures that JAX/numpy are already installed.
# ------------------------------------------------------------------------------
RUN Rscript -e "library(fastrerandomize); fastrerandomize::build_backend(conda='auto')"
# ------------------------------------------------------------------------------
# 5) Expose the Shiny port and set default command to run the Shiny app
# ------------------------------------------------------------------------------
EXPOSE 7860
CMD ["R", "--quiet", "-e", "shiny::runApp('/code', host='0.0.0.0', port=7860)"]