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 0be951c..c489734 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,17 +1,33 @@ FROM python:3.12-slim -# Basis tooling + wat je vaak nodig hebt +# Base tooling RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git curl \ libpq-dev \ + ca-certificates \ && rm -rf /var/lib/apt/lists/* -# Niet-root user voor dev +# 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/* + +# Non-root dev user RUN useradd -m vscode USER vscode WORKDIR /workspace -# uv installeren (user-local) +ENV PATH="/home/vscode/.local/bin:${PATH}" + +# Install uv RUN curl -LsSf https://astral.sh/uv/install.sh | sh -ENV PATH="/home/vscode/.local/bin:${PATH}" \ No newline at end of file + +# Install Claude Code CLI +RUN curl -fsSL https://claude.ai/install.sh | bash + +# 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 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ff3481d..58e3093 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,21 @@ { "name": "python-uv-dev", "build": { "dockerfile": "Dockerfile" }, - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "anthropic.claude-code" - ], - "postCreateCommand": "uv sync", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + }, + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "anthropic.claude-code" + ] + } + }, + "initializeCommand": "touch .devcontainer/.env", + "runArgs": ["--env-file", ".devcontainer/.env"], + "postCreateCommand": "bash .devcontainer/post-create.sh", "forwardPorts": [8501], "remoteUser": "vscode" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 0000000..6c7886d --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "Starting post-create setup..." + +# Install Python dependencies +uv sync + +# 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/python-uv-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 6786750..25d16a3 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,82 @@ # Python devcontainer met uv -Deze repository biedt een minimale development container voor Python-projecten met [uv](https://github.com/astral-sh/uv) als package manager. +Een kant-en-klare ontwikkelomgeving voor Python-projecten met [uv](https://github.com/astral-sh/uv) als package manager. 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 `uv sync`. -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 - uv run python -m src.main + git clone https://github.com/cedanl/python-uv-devcontainer + code python-uv-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/python-uv-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/python-uv-devcontainer +devcontainer up --workspace-folder python-uv-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 | +|------|-------------| +| `python` | Python 3.12 | +| `uv` | Snelle Python package manager | +| `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` |