|
| 1 | +# ----- R Package Dockerfile ----- |
| 2 | +# |
| 3 | +# This Dockerfile is designed for developers of any R package stored on GitHub. |
| 4 | +# |
| 5 | +# It runs several steps: |
| 6 | +# 1. Pulls the official bioconductor Docker container (which includes Rstudio). |
| 7 | +# 2. Runs CRAN checks on the R package. |
| 8 | +# 3. Installs the R package and all of its dependencies (including Depends, Imports, and Suggests). |
| 9 | +# |
| 10 | +# You can then create an image of the Docker container in any command line: |
| 11 | +# docker pull <DockerHub_repo_name>/<package_name> |
| 12 | +# Once the image has been created, you can launch it with: |
| 13 | +# docker run -d -e ROOT=true -e PASSWORD=bioc -v ~/Desktop:/Desktop -v /Volumes:/Volumes --rm -p 8788:8787 <DockerHub_repo_name>/<package_name> |
| 14 | +# Finally, launch the containerised Rstudio by entering the following URL in any web browser: |
| 15 | +# http://localhost:8788/ |
| 16 | +# |
| 17 | +# The username will be "rstudio" by default, |
| 18 | +# and you can set the password to whatever you like, |
| 19 | +# |
| 20 | +# This DockerFile was partly adapted from the [scFlow Dockerfile](https://github.com/combiz/scFlow/blob/master/Dockerfile). |
| 21 | +FROM $CONT |
| 22 | +RUN apt-get update && \ |
| 23 | + apt-get install -y \ |
| 24 | + git-core \ |
| 25 | + libcurl4-openssl-dev \ |
| 26 | + libgit2-dev \ |
| 27 | + libicu-dev \ |
| 28 | + libssl-dev \ |
| 29 | + make pandoc \ |
| 30 | + pandoc-citeproc \ |
| 31 | + zlib1g-dev \ |
| 32 | + xfonts-100dpi \ |
| 33 | + xfonts-75dpi \ |
| 34 | + biber \ |
| 35 | + libsbml5-dev \ |
| 36 | + qpdf \ |
| 37 | + cmake \ |
| 38 | + && apt-get clean \ |
| 39 | + && rm -rf /var/lib/apt/lists/* |
| 40 | +# Create a buildzone folder named after the R package |
| 41 | +# BiocCheck requires the buildzone to have the same name as the R package |
| 42 | +ARG PKG |
| 43 | +RUN echo $PKG |
| 44 | +RUN mkdir -p /$PKG |
| 45 | +ADD . /$PKG |
| 46 | +WORKDIR /$PKG |
| 47 | +# Install dependencies with AnVil (faster) |
| 48 | +RUN Rscript -e 'options(download.file.method="libcurl", crayon.enabled=TRUE, timeout=2000); \ |
| 49 | + if(!require("BiocManager")) install.packages("BiocManager"); \ |
| 50 | + if(!require("AnVIL")) {BiocManager::install("AnVIL", ask = FALSE)}; \ |
| 51 | + AnVIL::install(c("remotes","devtools")); \ |
| 52 | + try({remotes::install_github("bergant/rapiclient")}); \ |
| 53 | + bioc_ver <- BiocManager::version(); \ |
| 54 | + options(repos = c(AnVIL::repositories(),\ |
| 55 | + AnVIL = file.path("https://bioconductordocker.blob.core.windows.net/packages",bioc_ver,"bioc"),\ |
| 56 | + CRAN = "https://cran.rstudio.com/"),\ |
| 57 | + download.file.method = "libcurl", Ncpus = 2); \ |
| 58 | + deps <- remotes::dev_package_deps(dependencies = TRUE)$package; \ |
| 59 | + AnVIL::install(pkgs = deps, ask = FALSE); \ |
| 60 | + deps_left <- deps[!deps %in% rownames(installed.packages())]; \ |
| 61 | + if(length(deps_left)>0) devtools::install_dev_deps(dependencies = TRUE, upgrade = "never");' |
| 62 | +# Install R package from source |
| 63 | +RUN R -e 'options(crayon.enabled = TRUE); \ |
| 64 | + remotes::install_local(upgrade="never")' |
| 65 | +RUN rm -rf /$PKG |
0 commit comments