Created
April 30, 2021 19:36
-
-
Save aforsythe/b588c950965d5a6b4810bed4cf85873b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM r-base:4.0.4 | |
# Install required system components | |
RUN apt-get update && \ | |
apt-get install -y \ | |
libcurl4-openssl-dev \ | |
libssl-dev \ | |
libxml2-dev \ | |
libglpk-dev \ | |
libicu | |
# Create environment variables | |
ENV PATH=/opt/conda/condabin:/opt/conda/bin:${PATH} | |
ENV RENV_PATHS_ROOT=/root/project/renv | |
ENV RENV_PATHS_LIBRARY=/root/project/renv/library | |
ENV RETICULATE_MINICONDA_PATH=/opt/conda | |
ENV R_LIBS_SITE=/root/project/renv/library/R-4.0/x86_64-pc-linux-gnu:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library | |
# Create arguments. Values passed from docker-compose.yml | |
ARG SEURAT_VERSION=dev | |
ARG RENV_VERSION=0.13.2 | |
ARG CONDA_VERSION=py38_4.9.2 | |
# Add environment variables to Renviron | |
RUN echo "" >> ${R_HOME}/etc/Renviron | |
RUN echo "RENV_PATHS_ROOT=${RENV_PATHS_ROOT}" >> ${R_HOME}/etc/Renviron | |
RUN echo "RENV_PATHS_LIBRARY=${RENV_PATHS_LIBRARY}" >> ${R_HOME}/etc/Renviron | |
RUN echo "RETICULATE_MINICONDA_PATH=${RETICULATE_MINICONDA_PATH}" >> ${R_HOME}/etc/Renviron | |
RUN echo "R_LIBS_SITE=${R_LIBS_SITE}" >> ${R_HOME}/etc/Renviron | |
# Install miniconda | |
RUN mkdir -p /root/project | |
WORKDIR /root/project/ | |
COPY environment.yml . | |
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh -O miniconda.sh && \ | |
mkdir -p /opt && \ | |
sh miniconda.sh -b -p /opt/conda && \ | |
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ | |
echo ". /opt/conda/etc/profile.d/conda.sh" >> /root/.shinit && \ | |
echo "conda activate base" >> /root/.shinit && \ | |
find /opt/conda/ -follow -type f -name '*.a' -delete && \ | |
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \ | |
conda update conda && \ | |
conda clean -afy && \ | |
conda env create -f environment.yml && \ | |
echo ". /opt/conda/etc/profile.d/conda.sh" >> /root/.bashrc && \ | |
echo "conda activate r-reticulate" >> /root/.bashrc | |
# Install the renv package and install packages from lockfile | |
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))" | |
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')" | |
# Restore R packages | |
WORKDIR /root/project/ | |
COPY renv.lock . | |
COPY renv ./renv/ | |
RUN R -e "renv::restore(lockfile='/root/project/renv.lock', library='/root/project/renv/library/R-4.0/x86_64-pc-linux-gnu')" | |
# Reinstall stringi due to issue with libicu, this is a work around because installing libicu-dev doesn't work | |
RUN R -e "install.packages('stringi')" | |
# Copy data | |
COPY data ./data/ | |
COPY results ./results/ | |
COPY rmarkdown ./rmarkdown/ | |
COPY scripts ./scripts/ | |
# Run R script | |
CMD ["Rscript", "--verbose", "./scripts/scMC_EC_new.R"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment