diff --git a/r/Dockerfile b/r/Dockerfile index 697ddf5..c513971 100644 --- a/r/Dockerfile +++ b/r/Dockerfile @@ -75,21 +75,24 @@ ARG MAMBA_DOCKERFILE_ACTIVATE=1 # Install BigelowLab dev R libs # RUN installGithub.R BigelowLab/rasf BigelowLab/ohwobpg # not working on GH but works locally :-/ -RUN Rscript -e "remotes::install_cran('assertthat', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('ggspatial', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('plot.matrix', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('isdparser', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('geonames', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('rnoaa', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('hadley/emo', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/ohwobpg', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/rasf', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/xyzt', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/ghrsst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/bsw', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/ersst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/hycom', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('kwstat/pals', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" +#RUN Rscript -e "remotes::install_cran('assertthat', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('ggspatial', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('plot.matrix', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('isdparser', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('geonames', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('rnoaa', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('hadley/emo', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/ohwobpg', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/rasf', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/xyzt', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/ghrsst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/bsw', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/ersst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/hycom', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('kwstat/pals', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" +COPY ./install.R ./remotes.yml ./ + +RUN Rscript install.R remotes.yml COPY CONDARC ./.condarc diff --git a/r/install.R b/r/install.R new file mode 100644 index 0000000..d51e283 --- /dev/null +++ b/r/install.R @@ -0,0 +1,45 @@ +# Install one or more R packages using remotes package +# +# Input/Output: +# @param single argument with fully qualified name to (yaml) configuration file +# @return 0 for success, non-zero if an issue arises. Fails soon. +# +# Usage: +# Rscript /path/to/install.R /path/to/remotes.yml +# +library(yaml) +library(remotes) + +x <- yaml::read_yaml(commandArgs(trailingOnly = TRUE)[1]) + +args <- x$extra + +if ('install_cran' %in% names(x)){ + for (p in x[['install_cran']]){ + ok <- try(remotes::install_cran(p, + dependencies=args$dependencies, + upgrade_dependencies=args$upgrade_dependencies, + upgrade=args$upgrade)) + if (inherits(ok, 'try-error')){ + print("unable to install package:", p) + print(ok) + quit(save = "no", status = 1) + } + } +} + +if ('install_github' %in% names(x)){ + for (p in x[['install_github']]){ + ok <- try(remotes::install_github(p, + dependencies=args$dependencies, + upgrade_dependencies=args$upgrade_dependencies, + upgrade=args$upgrade)) + if (inherits(ok, 'try-error')){ + + print(ok) + quit(save = "no", status = 1) + } + } +} + +quit(save = "no", status = 0) \ No newline at end of file diff --git a/r/remotes.yml b/r/remotes.yml new file mode 100644 index 0000000..1d8cbf5 --- /dev/null +++ b/r/remotes.yml @@ -0,0 +1,22 @@ +extra: + dependencies: no + upgrade_dependencies: no + upgrade: no +install_cran: +- assertthat +- ggspatial +- plot.matrix +- isdparser +- geonames +- rnoaa +install_github: +- hadley/emo +- BigelowLab/ohwobpg +- BigelowLab/rasf +- BigelowLab/xyzt +- BigelowLab/ghrsst +- BigelowLab/bsw +- BigelowLab/ersst +- BigelowLab/ersst +- BigelowLab/hycom +- kwstat/pals