|
| 1 | +# RStudio Server Setup |
| 2 | + |
| 3 | +- [Docker Compose Configuration](#docker-compose-configuration) |
| 4 | + - [Quick Start](#quick-start) |
| 5 | + - [Configuration](#configuration) |
| 6 | + - [Commands](#commands) |
| 7 | + - [Troubleshooting](#troubleshooting) |
| 8 | +- [Integration with AI Agents](#integration-with-ai-agents) |
| 9 | + - [Remote LLMs](#remote-llms) |
| 10 | + - [Local LLM](#local-llm) |
| 11 | +- [References](#references) |
| 12 | + |
| 13 | +## Docker Compose Configuration |
| 14 | + |
| 15 | +This Docker Compose configuration sets up RStudio Server using the `rocker/tidyverse` image. |
| 16 | + |
| 17 | +### Quick Start |
| 18 | + |
| 19 | +1. **Set your password**: |
| 20 | + ```bash |
| 21 | + # Edit .env file and set RSTUDIO_PASSWORD |
| 22 | + nano .env |
| 23 | + ``` |
| 24 | + |
| 25 | +2. **Start RStudio Server**: |
| 26 | + ```bash |
| 27 | + docker compose up -d |
| 28 | + ``` |
| 29 | + |
| 30 | +3. **Access RStudio**: |
| 31 | + - URL: http://localhost:8787 |
| 32 | + - Username: `rstudio` |
| 33 | + - Password: (as set in .env file) |
| 34 | + |
| 35 | +### Configuration |
| 36 | + |
| 37 | +Environment variables: |
| 38 | +- `RSTUDIO_PASSWORD`: Password for the rstudio user |
| 39 | +- `USER`: Your system username for volume mounting |
| 40 | + |
| 41 | +Volumes: |
| 42 | +- `./data`: Persistent data storage |
| 43 | +- `./projects`: R projects directory |
| 44 | +- `/home/${USER}/apps`: Read-only mount of your apps directory |
| 45 | + |
| 46 | +Network: |
| 47 | +- Connected to `ai-agents-net` for integration with [local Ollama services](../ai-agents/). |
| 48 | + |
| 49 | +### Commands |
| 50 | + |
| 51 | +```bash |
| 52 | +# Start the service |
| 53 | +docker compose up -d |
| 54 | + |
| 55 | +# View logs |
| 56 | +docker compose logs -f |
| 57 | + |
| 58 | +# Stop the service |
| 59 | +docker compose down |
| 60 | + |
| 61 | +# Restart the service |
| 62 | +docker compose restart |
| 63 | + |
| 64 | +# Access container shell |
| 65 | +docker compose exec rstudio-server bash |
| 66 | +``` |
| 67 | + |
| 68 | +### Troubleshooting |
| 69 | + |
| 70 | +**Common Issues**: |
| 71 | +1. **Port 8787 already in use**: |
| 72 | + ```bash |
| 73 | + sudo lsof -i :8787 |
| 74 | + # Kill any processes using the port |
| 75 | + ``` |
| 76 | + |
| 77 | +2. **Can't access from remote**: |
| 78 | + - Ensure firewall allows port 8787 |
| 79 | + - Use SSH tunnel for secure remote access: |
| 80 | + ```bash |
| 81 | + ssh -L 8787:localhost:8787 username@hostname |
| 82 | + ``` |
| 83 | + |
| 84 | +## Integration with AI Agents |
| 85 | + |
| 86 | +### Remote LLMs |
| 87 | + |
| 88 | +To enable Copilot integration in RStudio Server, add the following line to the R session configuration file: |
| 89 | + |
| 90 | +``` |
| 91 | +# Edit rsession config file |
| 92 | +nano /etc/rstudio/rsession.conf |
| 93 | +``` |
| 94 | + |
| 95 | +Add the line: |
| 96 | +> copilot-enabled=1 |
| 97 | +
|
| 98 | +And than restart RStudio Server and follow the [instructions to setup Copilot in RStudio](https://docs.posit.co/ide/user/ide/guide/tools/copilot.html). |
| 99 | + |
| 100 | +### Local LLM |
| 101 | + |
| 102 | +RStudio Server is connected to the `ai-agents-net` network, allowing it to communicate with: |
| 103 | + |
| 104 | +- Ollama (http://ollama:11434) |
| 105 | +- Open WebUI (http://open-webui:8080) |
| 106 | +- Other MCP servers. |
| 107 | + |
| 108 | +:note: Use `chattr` package for dialog with OpenAI, Anthropic, or other remote LLMs. |
| 109 | + |
| 110 | +## References |
| 111 | + |
| 112 | +1. [Rocker Project](https://rocker-project.org/images/versioned/rstudio.html) |
| 113 | +2. [Docker Hub: rocker/tidyverse](https://hub.docker.com/r/rocker/tidyverse) |
0 commit comments