From c26ad276ea014ca50f2b52dcacae6e6133e8db84 Mon Sep 17 00:00:00 2001 From: gowerc Date: Thu, 26 Sep 2024 14:09:58 +0100 Subject: [PATCH] Further refinements --- CONTRIBUTING.md | 5 +++++ misc/docker/Dockerfile | 4 ++-- misc/docker/install_packages.R | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0dedfb822..07525cbe2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,6 +75,11 @@ To support CI/CD, in terms of reducing setup time, a Docker images has been crea This image is automatically re-built once a month to contain the latest version of R and its packages. The code to create this images can be found in `misc/docker`. +To build the image locally run the following from the project root directory: +``` +docker build -f misc/docker/Dockerfile -t rbmi:latest . +``` + ### Reproducibility, Print Tests & Snaps diff --git a/misc/docker/Dockerfile b/misc/docker/Dockerfile index 934fcb8f1..03b62f943 100644 --- a/misc/docker/Dockerfile +++ b/misc/docker/Dockerfile @@ -42,8 +42,8 @@ RUN apt-get update -y --fix-missing && \ apt-get upgrade -y && \ apt-get install -y $REQD_PKGS -ADD install_packages.R / -ADD ../../DESCRIPTION / +ADD misc/docker/install_packages.R / +ADD DESCRIPTION / RUN Rscript /install_packages.R diff --git a/misc/docker/install_packages.R b/misc/docker/install_packages.R index b1200e6ae..d32e5e197 100644 --- a/misc/docker/install_packages.R +++ b/misc/docker/install_packages.R @@ -30,13 +30,29 @@ if (!requireNamespace("desc", quietly = TRUE)) { install.packages("desc") } + +# Get a list of all packages that we claim we depend on in the DESCRIPTION file pkgs <- desc::desc("DESCRIPTION")$get_deps()$package |> unique() # Add on additional packages that might be needed in the future pkgs <- c(pkgs, "tidyverse") + +# R will error if you try to update the base packages so remove them +# if they are in any of the imports / suggests / depends list +base_pkgs <- c( + "KernSmooth", "class", "foreign", "methods", "rpart", "survival", + "MASS", "cluster", "grDevices", "mgcv", "spatial", "tcltk", + "Matrix", "codetools", "graphics", "nlme", "splines", "tools", + "base", "compiler", "grid", "nnet", "stats", "translations", + "boot", "datasets", "lattice", "parallel", "stats4", "utils", + "R" +) +pkgs <- pkgs[!pkgs %in% base_pkgs] + install.packages(pkgs, dependencies = TRUE) +# Install cmdstanr (not available from CRAN) install.packages( "cmdstanr", repos = c("https://stan-dev.r-universe.dev", getOption("repos"))