From f40f261b35c20211e65d98aff2b347c6c28ba46f Mon Sep 17 00:00:00 2001 From: ryanlovett Date: Tue, 20 Feb 2024 15:43:21 -0800 Subject: [PATCH] Source additional env vars from Renviron.site. This should enable R and RStudio to read dynamically created files. Part of #5551. --- deployments/datahub/images/default/Dockerfile | 5 +++++ .../images/default/Renviron.site.append | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 deployments/datahub/images/default/Renviron.site.append diff --git a/deployments/datahub/images/default/Dockerfile b/deployments/datahub/images/default/Dockerfile index d97f276e3..5bc9ac006 100644 --- a/deployments/datahub/images/default/Dockerfile +++ b/deployments/datahub/images/default/Dockerfile @@ -61,6 +61,11 @@ RUN curl --silent --location --fail ${SHINY_SERVER_URL} > /tmp/shiny-server.deb COPY Rprofile.site /usr/lib/R/etc/Rprofile.site # RStudio needs its own config COPY rsession.conf /etc/rstudio/rsession.conf +# Enable customizations to Renviron.site +COPY Renviron.site.append /tmp/Renviron.site.append +RUN cat /tmp/Renviron.site.append >> /etc/R/Renviron.site && \ + mkdir /etc/R/Renviron.site.d/ && \ + rm /tmp/Renviron.site.append # R_LIBS_USER is set by default in /etc/R/Renviron, which RStudio loads. # We uncomment the default, and set what we wanna - so it picks up diff --git a/deployments/datahub/images/default/Renviron.site.append b/deployments/datahub/images/default/Renviron.site.append new file mode 100644 index 000000000..6b34740c8 --- /dev/null +++ b/deployments/datahub/images/default/Renviron.site.append @@ -0,0 +1,20 @@ + +## Source any extra Renviron files. +# +# Since there is an existing /etc/R/Renviron.site file, we append this. It lets +# us easily add new code via extraFiles (or other z2jh-related magic) +# without having to rebuild the image each time. + + +# Get a list of files in the directory +env_dir <- "/etc/R/Renviron.site.d/" +env_files <- list.files(env_dir, full.names = TRUE) + +# Iterate over each file +for (env_file in env_files) { + cat("Loading environment variables from:", env_file, "\n") + + # Read and parse the environment file + readRenviron(env_file) +} +