feat(templates): add docker-rstudio template with code-server and RMarkdown#819
feat(templates): add docker-rstudio template with code-server and RMarkdown#819
Conversation
…rkdown Add a new Docker-based template for R development that provisions a workspace with RStudio Server, code-server, and RMarkdown pre-configured. The template uses the rocker/rstudio image which ships R and RStudio Server pre-installed, and leverages the code-server registry module for VS Code in the browser. RMarkdown is installed on first start and persisted in the home-directory R library across restarts.
Co-authored-by: DevCats <christofer@coder.com>
The rocker/rstudio base image does not ship with curl or cmake. curl is required by the code-server module to download the install script, and cmake is needed to compile the R "fs" package (a transitive dependency of rmarkdown). Because all coder_script resources run in parallel via errgroup, there is no way to guarantee an apt-get install in the startup_script finishes before the code-server module tries to use curl. Building a custom image with these dependencies baked in is the only reliable fix.
|
I pushed a commit that adds a Since this template uses
There's currently no way for modules like Longer term, it might be worth adding |
|
@Shelnutt2 I made some changes to the template since some of the modules required some pre-reqs that were not available in the Let me know if you are cool with this, and we can get this merged unless you have some other ideas 😄 |
Nah this is good, thanks for the help here. |
…artup Moves the rmarkdown install from the startup_script into the Dockerfile. This eliminates ~14k lines of R package compilation logs on every workspace start and lets the workspace go healthy immediately instead of blocking on source compilation of 25 R package dependencies.
…alls The rocker/rstudio image is pre-configured to use Posit Package Manager (p3m.dev) which serves pre-compiled binary R packages. Dropping the explicit repos argument avoids overriding this with CRAN source, which was forcing full source compilation.
The fileset/filesha1 triggers block causes a nil pointer dereference in Coder dynamic parameters preview due to the fileset stub returning cty.String instead of cty.Set(cty.String). Since each workspace builds its own image on every start, the triggers block is not needed.
rserver with --server-daemonize=0 holds stdout/stderr open when backgrounded, causing Coder to warn about unclosed output pipes after the startup script exits. Redirecting to /tmp/rserver.log fixes this.
The Coder agent runs as root, so $(whoami) resolves to root. RStudio Server cannot spawn rsession processes for root, causing the jsonrpc error. Hardcode --server-user=rstudio to match the default user in the rocker/rstudio image.
New Template: docker-rstudio
Adds a Docker-based template for R development workspaces.
What it provides
rocker/rstudioimageregistry.coder.com/coder/code-server/codermoduleDesign decisions
Click to expand
rocker/rstudioas the base image instead ofcodercom/enterprise-base:ubuntu+ therstudio-servermodule. The module runs RStudio inside a nested Docker container which requires Docker-in-Docker or socket mounting in the workspace. Using the rocker image directly avoids that complexity and starts faster since R and RStudio are already installed.coder_appfor RStudio rather than the registryrstudio-servermodule, because the module is designed for Docker-based provisioning (it pulls and runs a rocker container). Since the workspace itself is the rocker container, RStudio Server is started natively viarserver.require('rmarkdown')before installing. Since R libraries default to a subdirectory under/home/rstudio(the persistent volume), packages survive workspace restarts./home/rstudioto match the default user in the rocker image.--auth-none=1disables RStudio authentication since the Coder proxy handles access control.Files added
registry/coder/templates/docker-rstudio/main.tfregistry/coder/templates/docker-rstudio/README.mdValidation
go run ./cmd/readmevalidation/— passes (32 templates detected)terraform fmt— cleanbun run fmt— all files unchanged