diff --git a/.devcontainer/.env.example b/.devcontainer/.env.example new file mode 100644 index 0000000..e1cdb94 --- /dev/null +++ b/.devcontainer/.env.example @@ -0,0 +1,4 @@ +# Copy this file to .env and fill in your values. +# Used as fallback when env vars are not set on the host machine. +ANTHROPIC_FOUNDRY_API_KEY= +ANTHROPIC_FOUNDRY_RESOURCE= diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5be965e..20b0305 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,6 +10,7 @@ RUN apt-get update && \ libssl-dev \ libxml2-dev \ curl \ + ca-certificates \ vim \ git \ build-essential \ @@ -20,5 +21,21 @@ RUN apt-get update && \ libgit2-dev \ && rm -rf /var/lib/apt/lists/* +# Install Node.js LTS (needed for npx/skills) +RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ + apt-get install -y --no-install-recommends nodejs && \ + rm -rf /var/lib/apt/lists/* + USER rstudio WORKDIR /workspace + +# Install Claude Code CLI +RUN curl -fsSL https://claude.ai/install.sh | bash + +ENV PATH="/home/rstudio/.local/bin:${PATH}" + +# Claude / Anthropic environment +ENV CLAUDE_CODE_USE_FOUNDRY=1 \ + ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-6 \ + ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6 \ + ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-6 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 19008ba..913f147 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,9 +4,18 @@ "dockerfile": "Dockerfile" }, "remoteUser": "rstudio", - "settings": {}, - "extensions": [ - "REditorSupport.r" - ], - "postCreateCommand": "Rscript -e 'install.packages(c(\"devtools\", \"usethis\", \"pak\", \"renv\"), repos=\"https://cran.rstudio.com/\")'" + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + }, + "extensions": [ + "REditorSupport.r", + "anthropic.claude-code" + ] + } + }, + "initializeCommand": "touch .devcontainer/.env", + "runArgs": ["--env-file", ".devcontainer/.env"], + "postCreateCommand": "bash .devcontainer/post-create.sh" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 0000000..c51048c --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "Starting post-create setup..." + +# Install core R packages +Rscript -e 'install.packages(c("devtools", "usethis", "pak", "renv"), repos="https://cran.rstudio.com/")' + +# Install org-wide Claude/OpenCode skills from cedanl/.github +npx --yes skills add cedanl/.github --skill '*' -a claude-code -a opencode -y --copy -g + +# Source .env file on shell startup (fallback for secrets not set on host) +ENV_FILE="/workspaces/r-devcontainer/.devcontainer/.env" +echo "[ -f \"$ENV_FILE\" ] && set -a && source \"$ENV_FILE\" && set +a" >> ~/.bashrc + +echo "Post-create complete." diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d41a0c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.devcontainer/.env diff --git a/README.md b/README.md index 99222ed..ca11569 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,82 @@ # R devcontainer -Deze repository biedt een minimale development container voor R-projecten, geïnspireerd door de python-uv-devcontainer. +Een kant-en-klare ontwikkelomgeving voor R-projecten op basis van [rocker/tidyverse](https://rocker-project.org/). Inclusief Claude Code CLI en CEDA org-skills. -## Gebruik +## Vereisten + +**Docker is verplicht** — zonder Docker werkt geen van onderstaande methoden. + +- **Windows / macOS**: installeer [Docker Desktop](https://www.docker.com/products/docker-desktop/) +- **Linux**: installeer [Docker Engine](https://docs.docker.com/engine/install/) -1. Clone deze repo naar GitHub (bijv. als template voor je organisatie). -2. Open de map in VS Code. -3. Kies: `Reopen in Container` (Dev Containers / Codespaces). -4. Dependencies worden automatisch geïnstalleerd via het R-script in `postCreateCommand`. -5. Run de app: +## Opstarten +### VS Code + +1. Installeer de extensie **Dev Containers** (`ms-vscode-remote.remote-containers`) +2. Clone de repo en open de map: ```bash - Rscript src/main.R + git clone https://github.com/cedanl/r-devcontainer + code r-devcontainer ``` +3. Klik op **"Reopen in Container"** rechtsonder, of `F1` → **Dev Containers: Reopen in Container** -## Vereisten +### Positron + +Clone de repo en open de map in Positron. Positron detecteert de `.devcontainer/devcontainer.json` automatisch en vraagt of je wilt heropenen in een container. + +### DevPod + +```bash +devpod up github.com/cedanl/r-devcontainer +``` + +Of via de [DevPod UI](https://devpod.sh/): **Create Workspace** → voer de repository-URL in. + +### Devcontainer CLI + +```bash +npm install -g @devcontainers/cli +git clone https://github.com/cedanl/r-devcontainer +devcontainer up --workspace-folder r-devcontainer +``` + +## Claude Code instellen + +Claude Code is vooraf geïnstalleerd, maar heeft twee credentials nodig voor de CEDA Foundry API. + +**Stap 1** — Maak het secrets-bestand aan: +```bash +cp .devcontainer/.env.example .devcontainer/.env +``` + +**Stap 2** — Vul je credentials in in `.devcontainer/.env`: +``` +ANTHROPIC_FOUNDRY_API_KEY= +ANTHROPIC_FOUNDRY_RESOURCE= +``` + +> Dit bestand staat in `.gitignore` en wordt nooit gecommit. + +**Stap 3** — `F1` → **Dev Containers: Rebuild Container** + +Na het herbouwen werkt `claude` meteen. + +## Wat zit er in de container? + +| Tool | Beschrijving | +|------|-------------| +| `R` + tidyverse | R met vooraf geïnstalleerde tidyverse-pakketten | +| `devtools`, `pak`, `renv` | R-pakketbeheer en projectbeheer | +| `claude` | Claude Code CLI | +| `gh` | GitHub CLI | +| CEDA org-skills | Geladen vanuit `cedanl/.github` via `npx skills` | -- Docker moet geïnstalleerd en actief zijn op je machine (of je gebruikt GitHub Codespaces met container support). -- Een editor die met devcontainers overweg kan, zoals VS Code + de Dev Containers-extensie of GitHub Codespaces. +## Problemen oplossen -**Zonder Docker (of een equivalente container runtime) kan deze setup niet werken**, omdat de volledige ontwikkelomgeving in de container draait. +| Probleem | Oplossing | +|----------|-----------| +| "Cannot connect to Docker daemon" | Zorg dat Docker draait | +| Container bouwt niet | Controleer je internetverbinding | +| `claude` geeft API-fout | Controleer `.devcontainer/.env` en rebuild | +| Skills niet geladen | `npx skills add cedanl/.github --skill '*' -a claude-code -y --copy -g` |