-
Notifications
You must be signed in to change notification settings - Fork 46
add: rstudio module #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add: rstudio module #327
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new RStudio Server module for Coder that deploys RStudio Server using the Rocker Project Docker distribution. The module provides a consistent and stable way to run RStudio Server in Coder workspaces, handling authentication, project mounting, and R environment management with renv support.
- Adds Docker-based RStudio Server deployment with configurable authentication and project paths
- Implements renv cache volume for dependency persistence and automatic environment restoration
- Provides comprehensive Terraform configuration with variables for customization and Coder app integration
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 5 comments.
File | Description |
---|---|
registry/coder/modules/rstudio-server/main.tf | Terraform configuration defining variables, script execution, and Coder app setup |
registry/coder/modules/rstudio-server/run.sh | Shell script that manages Docker operations, container lifecycle, and renv restoration |
registry/coder/modules/rstudio-server/README.md | Documentation with module description and basic usage example |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
delay=2 | ||
attempt=1 | ||
|
||
while ! docker ps; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docker readiness check only verifies that docker ps
succeeds but doesn't handle potential authentication or permission issues. Consider redirecting stderr to /dev/null and adding a more specific check like docker ps > /dev/null 2>&1
to avoid cluttering output with error messages during the retry loop.
while ! docker ps; do | |
while ! docker ps > /dev/null 2>&1; do |
Copilot uses AI. Check for mistakes.
# Make RENV_CACHE_VOLUME writable to USER | ||
docker exec rstudio-server bash -c 'chmod -R 0777 /renv/cache' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting permissions to 0777 (world-writable) creates a security risk by allowing any user to modify the renv cache. Consider using more restrictive permissions like 0755 or 0775, or setting ownership to the specific user instead.
# Make RENV_CACHE_VOLUME writable to USER | |
docker exec rstudio-server bash -c 'chmod -R 0777 /renv/cache' | |
# Make RENV_CACHE_VOLUME owned and writable by USER (not world-writable) | |
docker exec rstudio-server bash -c 'chown -R "${RSTUDIO_USER}":"${RSTUDIO_USER}" /renv/cache && chmod -R 0775 /renv/cache' |
Copilot uses AI. Check for mistakes.
if [ "${ENABLE_RENV}" = "true" ] && [ -f "${PROJECT_PATH}/renv.lock" ]; then | ||
echo "Restoring R environment via renv..." | ||
docker exec -u "${RSTUDIO_USER}" rstudio-server R -q -e \ | ||
'if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv", repos="https://cloud.r-project.org"); renv::restore(prompt = FALSE)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The R command execution lacks error handling. If the renv::restore() command fails, the script continues without indication of failure. Consider adding error checking or using set -e
behavior by checking the exit code of the docker exec command.
'if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv", repos="https://cloud.r-project.org"); renv::restore(prompt = FALSE)' | |
'if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv", repos="https://cloud.r-project.org"); renv::restore(prompt = FALSE)' | |
if [ $? -ne 0 ]; then | |
echo "Error: renv::restore() failed inside the container." | |
exit 1 | |
fi |
Copilot uses AI. Check for mistakes.
variable "rstudio_password" { | ||
type = string | ||
description = "RStudio password" | ||
default = "rstudio" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a hardcoded default password 'rstudio' creates a security vulnerability as it's easily guessable. Consider generating a random password by default or requiring users to explicitly set this variable without providing a weak default.
default = "rstudio" |
Copilot uses AI. Check for mistakes.
display_name = "rstudio-server" | ||
icon = "/icon/rstudio.svg" | ||
script = templatefile("${path.module}/run.sh", { | ||
DOCKER_HOST : var.docker_socket, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DOCKER_HOST environment variable is set but never used in the run.sh script. The script uses the default docker commands without specifying a custom socket. Either remove this variable or update the script to use DOCKER_HOST when provided.
DOCKER_HOST : var.docker_socket, |
Copilot uses AI. Check for mistakes.
Description
This PR brings RStudio Server module. Since full RStudio distribution is hard to install in a consistent, stable way (lib versions, deps, etc.), this module bases on Docker distribution - Rocker.
Type of Change
Module Information
Path:
registry/coder/modules/rstudio
New version:
v0.9.0
Breaking change: [ ] Yes [ ] No
Testing & Validation
bun test
)bun run fmt
)