Deploying a RStudio App
Introduction
RStudio (Posit Workbench open-source edition) is a web-based IDE for R development, data analysis, and visualization. Deploying RStudio with a Dockerfile on Klutch.sh provides reproducible environments, managed secrets, and persistent storage—all configured from klutch.sh/app. This guide covers installation, Dockerfile setup, environment variables, storage, Nixpacks overrides, and sample R code to verify your instance.
Prerequisites
- A Klutch.sh account (sign up)
- A GitHub repository containing your RStudio Dockerfile (GitHub is the only supported git source)
- Optional: external databases or storage your R workflows will query
For onboarding, see the Quick Start.
Architecture and ports
- RStudio Server serves HTTP on internal port
8787. Choose HTTP traffic in Klutch.sh and set the internal port to8787. - Persistent storage is recommended for user home directories and projects.
Repository layout
rstudio/├── Dockerfile # Must be at repo root for auto-detection└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Build and run locally:
docker build -t rstudio-local .docker run -p 8787:8787 \ -e PASSWORD=changeme \ -e USER=rstudio \ rstudio-localDockerfile for RStudio (production-ready)
Place this at the repo root; Klutch.sh auto-detects Dockerfiles.
FROM rocker/rstudio:latest
ENV USER=rstudioENV PASSWORD=changemeENV PORT=8787
EXPOSE 8787CMD ["/init"]Notes:
- Pin to a specific tag (e.g.,
rocker/rstudio:4.3.1) for stability. /initstarts the RStudio Server on port 8787 inside the container.
Environment variables (Klutch.sh)
Set these before deploying:
PORT=8787USER=rstudioPASSWORD=<secure-password>- Optional:
ROOT=TRUEif you need root privileges within the container (use cautiously)
If deploying without the Dockerfile and relying on Nixpacks:
NIXPACKS_START_CMD=/init
Attach persistent volumes
Add storage in Klutch.sh (path and size only):
/home/rstudio— user projects and libraries./var/lib/rstudio— server state (optional).
Ensure paths are writable inside the container.
Deploy RStudio on Klutch.sh (Dockerfile workflow)
- Push your repository—with the Dockerfile at the root—to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Select HTTP traffic and set the internal port to
8787. - Add environment variables (user, password, and optional root flag).
- Attach volumes at
/home/rstudio(and/var/lib/rstudioif desired) sized for your projects. - Deploy. Access RStudio at
https://example-app.klutch.shand log in with the configured user/password.
Sample R code to verify
Create a quick plot via the console:
x <- rnorm(1000)png("/home/rstudio/plot.png")hist(x, breaks = 30, col = "skyblue", main = "RStudio on Klutch.sh")dev.off()Health checks and production tips
- Add an HTTP readiness probe to
/(login page) to ensure the server is responding. - Keep credentials in Klutch.sh secrets; rotate passwords regularly.
- Pin image versions and test upgrades in staging before production.
- Monitor storage usage on
/home/rstudio; resize volumes as projects grow.
RStudio on Klutch.sh delivers reproducible Docker builds, managed secrets, and persistent workspaces—without extra YAML or CI steps. Configure ports, credentials, and storage, then start analyzing data in your browser.