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

Commit

Permalink
Export env var that start with APP_ to RStudio session (#9)
Browse files Browse the repository at this point in the history
* Export env var that start with APP_ to RStudio session

* Add example to .env.example

* Specify APP_* in comments of .env.example

* Update .env.example

Co-authored-by: Nicole Kauer <nicole.kauer@sagebase.org>

Co-authored-by: Nicole Kauer <nicole.kauer@sagebase.org>
  • Loading branch information
tschaffter and Aryllen authored May 28, 2021
1 parent 4711f90 commit efb6470
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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

0 comments on commit efb6470

Please sign in to comment.