Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
brucehoff committed Nov 13, 2024
2 parents 180c8a6 + 2a20812 commit 4a3e72c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ ENV DISABLE_AUTH=true
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get -y install libpng-dev \
libcurl4-openssl-dev \
libxml2-dev \
libfontconfig1-dev \
libgit2-dev \
libfontconfig1-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
libharfbuzz-dev \
python3 \
python3-pip \
python3-venv \
Expand All @@ -20,9 +31,13 @@ USER rstudio
RUN python3 -m pip install virtualenv

# Install R packages
RUN R -e "install.packages(c('tidyverse','devtools','BiocManager', 'reticulate'))"
ADD install_packages_or_fail.R /
ADD install_versioned_package_or_fail.R /
# synapser depends on rjson 0.2.21, but a newer version is installed by default
RUN Rscript --no-save install_versioned_package_or_fail.R rjson 0.2.21
RUN Rscript --no-save install_packages_or_fail.R tidyverse devtools BiocManager reticulate
# Install synapser and, by extension, the synapse Python client
RUN R -e "install.packages('synapser', repos=c('http://ran.synapse.org', 'http://cran.fhcrc.org'))"
RUN Rscript --no-save install_packages_or_fail.R synapser
# Install Python package boto3, which will be used by the synapse Python client
RUN R -e "reticulate::virtualenv_install(reticulate::virtualenv_list()[1], 'boto3')"

Expand Down
15 changes: 15 additions & 0 deletions install_packages_or_fail.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env Rscript
# from https://stackoverflow.com/questions/26244530/how-do-i-make-install-packages-return-an-error-if-an-r-package-cannot-be-install
# install the latest versions of a list of packages and fail
# if any package fails to install

packages = commandArgs(trailingOnly=TRUE)

for (l in packages) {

install.packages(l, dependencies=TRUE, repos=c('http://ran.synapse.org', 'https://cran.rstudio.com'))

if ( ! library(l, character.only=TRUE, logical.return=TRUE) ) {
quit(status=1, save='no')
}
}
15 changes: 15 additions & 0 deletions install_versioned_package_or_fail.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env Rscript
# install a specific version of a given package and fail if
# the package fails to install

theargs = commandArgs(trailingOnly=TRUE)

package=theargs[1]
version=theargs[2]

install.packages('remotes', dependencies=TRUE, repos='https://cran.rstudio.com')
remotes::install_version(package, version = version, repos = 'https://cran.rstudio.com')

if ( ! library(package, character.only=TRUE, logical.return=TRUE) ) {
quit(status=1, save='no')
}

0 comments on commit 4a3e72c

Please sign in to comment.