-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rstudio-server to r image as rstudio image
- Loading branch information
Showing
7 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,10 @@ | |
renv.lock.bak | ||
renv/ | ||
.tests.R | ||
|
||
# rstudio-server directories | ||
*.config | ||
*.local | ||
|
||
# R files | ||
.Rhistory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,8 @@ services: | |
target: add-package | ||
args: | ||
- PACKAGE | ||
|
||
rstudio: | ||
extends: r | ||
image: rstudio | ||
build: | ||
target: rstudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
git | ||
libclang-dev | ||
lsb-release | ||
psmisc | ||
sudo | ||
wget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# On Linux set rstudio user id to same as id of host if rstudio user id not already the same | ||
if [ "$HOSTPLATFORM" = "linux" -a "$(id -u rstudio)" != "$HOSTUID" ]; then | ||
usermod -u $HOSTUID rstudio | ||
fi | ||
|
||
# Check for 1 .Rproj file | ||
if [ $(find /workspace -type f -name "*.Rproj" | wc -w) -eq 1 ]; then | ||
|
||
# Copy in Git user.name and user.email from copied local-gitconfig from additionally mounted volume | ||
if test -f /home/rstudio/local-gitconfig; then | ||
grep -e "\[user\]" -e "name = *" -e "email = *" /home/rstudio/local-gitconfig >> /home/rstudio/.gitconfig | ||
fi | ||
|
||
# Avoid Git error: fatal detected dubious ownership of repository if using Git in container | ||
# Without this the Git pane fails to open when RStudio project opened | ||
echo -e "[safe]\n\tdirectory = \"*\"" >> /home/rstudio/.gitconfig | ||
|
||
# Open RStudio project on opening RStudio Server session | ||
echo 'setHook("rstudio.sessionInit", function(newSession) { if (newSession && is.null(rstudioapi::getActiveProject())) rstudioapi::openProject(paste0("/workspace/", list.files(pattern = "Rproj"))) }, action = "append")' >> /home/rstudio/.Rprofile | ||
fi | ||
|
||
# Set file line endings as crlf if docker run from Windows | ||
if [ "$HOSTPLATFORM" = "win32" ]; then | ||
echo -e "{\n\t\"line_ending_conversion\": \"windows\"\n}" >> /etc/rstudio/rstudio-prefs.json | ||
fi | ||
|
||
# Start RStudio Server session in foreground | ||
# Hence don't use `rstudio-server start` which runs in background | ||
# and attempt to capture std out and err to a metadata log file | ||
mkdir -p /workspace/metadata | ||
exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0 >> /workspace/metadata/rstudio.log 2>&1 |