Skip to content

feat(templates): add docker-rstudio template with code-server and RMarkdown#819

Open
Shelnutt2 wants to merge 11 commits intomainfrom
feat/docker-rstudio-template
Open

feat(templates): add docker-rstudio template with code-server and RMarkdown#819
Shelnutt2 wants to merge 11 commits intomainfrom
feat/docker-rstudio-template

Conversation

@Shelnutt2
Copy link
Copy Markdown

New Template: docker-rstudio

Adds a Docker-based template for R development workspaces.

What it provides

Tool Source Access
RStudio Server Pre-installed in rocker/rstudio image Browser via Coder proxy (subdomain)
code-server registry.coder.com/coder/code-server/coder module Browser via Coder proxy
RMarkdown Installed on first start, persisted in home-dir R library Available in both RStudio and code-server

Design decisions

Click to expand
  • rocker/rstudio as the base image instead of codercom/enterprise-base:ubuntu + the rstudio-server module. 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.
  • Direct coder_app for RStudio rather than the registry rstudio-server module, 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 via rserver.
  • RMarkdown installed idempotently — the startup script checks require('rmarkdown') before installing. Since R libraries default to a subdirectory under /home/rstudio (the persistent volume), packages survive workspace restarts.
  • Persistent volume mounted at /home/rstudio to match the default user in the rocker image.
  • --auth-none=1 disables RStudio authentication since the Coder proxy handles access control.

Files added

  • registry/coder/templates/docker-rstudio/main.tf
  • registry/coder/templates/docker-rstudio/README.md

Validation

  • go run ./cmd/readmevalidation/ — passes (32 templates detected)
  • terraform fmt — clean
  • bun run fmt — all files unchanged

…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.
Shelnutt2 and others added 4 commits March 30, 2026 14:44
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.
@blinkagent
Copy link
Copy Markdown
Contributor

blinkagent bot commented Mar 30, 2026

I pushed a commit that adds a build/Dockerfile and switches the docker_image resource to build from it instead of pulling rocker/rstudio directly.

Since this template uses rocker/rstudio instead of a Coder base image (which ships with common tools like curl), we're missing system dependencies that modules expect to be present:

  • curl — needed by the code-server module to download its install script
  • cmake — needed to compile the R fs package (transitive dep of rmarkdown) from source

There's currently no way for modules like code-server to declare or pre-install their own system-level prerequisites, and they assume the image already has them. So the fix is a thin Dockerfile that extends rocker/rstudio and adds the missing packages.

Longer term, it might be worth adding pre_install_script support to modules like code-server (similar to what claude-code already has) so templates using non-standard base images can orchestrate prerequisite installation before the module's main script runs.

@coder coder deleted a comment from blinkagent bot Mar 30, 2026
@DevelopmentCats
Copy link
Copy Markdown
Contributor

@Shelnutt2 I made some changes to the template since some of the modules required some pre-reqs that were not available in the rocker/rstudio image.

Let me know if you are cool with this, and we can get this merged unless you have some other ideas 😄

@Shelnutt2
Copy link
Copy Markdown
Author

@Shelnutt2 I made some changes to the template since some of the modules required some pre-reqs that were not available in the rocker/rstudio image.

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.

blink-so bot added 5 commits March 30, 2026 20:20
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants