Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Export env var that start with APP_ to RStudio session #9

Merged
merged 4 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ ROOT=FALSE
SYNAPSE_TOKEN=yourtoken

# Port on the host that connects to RStudio
HOST_PORT=80
HOST_PORT=80

# User-specified settings (APP_*) made visible to RStudio
APP_FOO=10
APP_BAR=hello
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ Example projects that use this repository / image:

- [Sage-Bionetworks-Challenges/challenge-analysis] (work in progress)

## Configuration

The configuration of the development environment is defined in the file `.env`.
This file contains environment variables that are set when the environment
starts.

For security reason, a user session in RStudio does not see all the environment
variables of the system. However, the variables defined in `.env` with a name
that starts with `APP_` will be made visible to the user session via the
creation of the file `.Renviron`.

```r
> variables <- names(s <- Sys.getenv())
> variables[startsWith(variables, "APP_")]
[1] "APP_BAR" "APP_FOO"
```

## Manage R and Python dependencies

### R
Expand Down
6 changes: 6 additions & 0 deletions root/etc/cont-init.d/30-configure-user
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ if [[ ! -z ${SYNAPSE_TOKEN} ]]; then
fi
fi

# Create .Renviron
> /home/${USER}/.Renviron
for var in "${!APP_@}"; do
echo "$var=${!var}" >> /home/${USER}/.Renviron
done

# Fix sudo: setrlimit(RLIMIT_CORE): Operation not permitted
# https://github.com/sudo-project/sudo/issues/42#issuecomment-659253293
echo "Set disable_coredump false" >> /etc/sudo.conf