🚧

DataPulse Analytics — Devcontainer

Entorno de desarrollo sandboxed con Claude Code · Python 3.12 + Node 22 + pnpm

configuracion-devcontainer-claude-code CULTIVA IA · IA-Ingenieria-MLOps

Stack detectado

Python 3.12 Node 22 / TypeScript pnpm (lockfile) Docker / devcontainer Claude Code + plugins
Listo para usar
📁

Archivos generados

.devcontainer/
datapulse-analytics/
  .devcontainer/
    ■ DockerfileNUEVO
    ■ devcontainer.jsonNUEVO
    ■ post_install.pyNUEVO
    ■ .zshrcNUEVO
    ■ install.shNUEVO
  src/
    api/ FastAPI
    ml/ churn models
    etl/ pipelines
  frontend/
    src/ Next.js 14
  pyproject.toml
  package.json
  pnpm-lock.yaml
  tsconfig.json

Capacidades incluidas

  • Claude Code + marketplace plugins
    anthropics/skills · trailofbits/skills · trailofbits/skills-curated
  • Sandboxing via bubblewrap + socat
    NET_ADMIN cap para aislamiento de red en modo seguro
  • Python 3.12 via uv (fast binary)
    Gestor ultra-rápido · venv en .venv · ruff formatter
  • Node 22 via fnm + pnpm 9
    pnpm install --frozen-lockfile en postCreate
  • Volúmenes Docker persistentes
    Historial bash/zsh · config Claude · credenciales gh
  • Token forwarding seguro
    ANTHROPIC_API_KEY y CLAUDE_CODE_OAUTH_TOKEN via remoteEnv
  • CLI tools: ripgrep · fzf · ast-grep · git-delta
    Búsqueda AST-aware + shell zsh con Oh My Zsh
{

devcontainer.json (fragmento clave)

devcontainer.json
{
  "name": "DataPulse Analytics",
  "build": {
    "dockerfile": "Dockerfile"
  },
  "features": {
    "ghcr.io/devcontainers/features/github-cli:1"
  },
  "runArgs": [
    "--cap-add=NET_ADMIN",
    "--cap-add=NET_RAW"
  ],
  "postCreateCommand":
    "rm -rf .venv && uv sync && uv run /opt/post_install.py && pnpm install --frozen-lockfile",
  "remoteEnv": {
    "ANTHROPIC_API_KEY":
      "${localEnv:ANTHROPIC_API_KEY:}",
    "CLAUDE_CODE_OAUTH_TOKEN":
      "${localEnv:CLAUDE_CODE_OAUTH_TOKEN:}"
  }
}
🔌

Extensiones VS Code instaladas

7 extensiones
anthropic.claude-code base
ms-python.python python
ms-python.vscode-pylance python
charliermarsh.ruff python
dbaeumer.vscode-eslint node
esbenp.prettier-vscode node
Formatter por lenguaje
[python] charliermarsh.ruff + organizeImports
editor.defaultFormatter esbenp.prettier-vscode
python.defaultInterpreterPath .venv/bin/python
💾

Volúmenes persistentes

Volumen Target Tipo
datapulse-analytics-bashhistory-* /commandhistory volume
datapulse-analytics-config-* /home/vscode/.claude volume
datapulse-analytics-gh-* /home/vscode/.config/gh volume
$HOME/.gitconfig /home/vscode/.gitconfig bind
.devcontainer/ /workspace/.devcontainer bind ro

postCreateCommand

Secuencia de arranque (Python + pnpm)
1. rm -rf .venv
   # Limpia venv previo

2. uv sync
   # Instala deps Python 3.12
   # FastAPI, pandas, scikit-learn...

3. uv run /opt/post_install.py
   # Bypass onboarding Claude Code
   # Config tmux 200k history
   # Permisos volúmenes

4. pnpm install --frozen-lockfile
   # Instala Next.js 14 + deps TS
   # Lockfile: pnpm-lock.yaml
Detección lockfile
pnpm-lock.yaml ✓ detectado → pnpm install --frozen-lockfile

Como iniciar

Opcion A — VS Code
Cmd+Shift+P
Reopen in Container
Opcion B — CLI
$ devcontainer up --workspace-folder .
Opcion C — Helper devc
$ .devcontainer/install.sh self-install
$ devc up
🔒 Token forwarding:
Exporta ANTHROPIC_API_KEY antes de lanzar. Claude Code lo recoge automaticamente via remoteEnv.
🛠

Dockerfile (secciones clave)

Dockerfile
# Multi-stage: uv binario sin overhead
FROM ghcr.io/astral-sh/uv:0.10 AS uv
FROM mcr.microsoft.com/devcontainers/base:ubuntu24.04

# Sandboxing Claude Code
RUN apt-get install -y bubblewrap socat \
  ripgrep fd-find fzf tmux \
  ipset iptables iproute2

# Python 3.12 (pyproject.toml requiere 3.12)
RUN uv python install 3.12 --default

# Node 22 via fnm + pnpm 9
RUN fnm install 22 && fnm default 22
RUN npm install -g pnpm@9

# Claude Code + marketplace plugins
RUN curl -fsSL https://claude.ai/install.sh | bash \
  && claude plugin marketplace add anthropics/skills \
  && claude plugin marketplace add trailofbits/skills
🔒

Variables de entorno

containerEnv + remoteEnv
containerEnv (build-time)
CLAUDE_CONFIG_DIR /home/vscode/.claude
UV_LINK_MODE copy
NPM_CONFIG_AUDIT true
NPM_CONFIG_MINIMUM_RELEASE_AGE 1440 (24h supply-chain protection)
PYTHONDONTWRITEBYTECODE 1
NODE_OPTIONS --max-old-space-size=4096
remoteEnv (runtime, desde host)
ANTHROPIC_API_KEY ${localEnv:ANTHROPIC_API_KEY:}
CLAUDE_CODE_OAUTH_TOKEN ${localEnv:CLAUDE_CODE_OAUTH_TOKEN:}
Seguridad de supply-chain:
NPM_CONFIG_MINIMUM_RELEASE_AGE=1440 bloquea paquetes publicados en las ultimas 24h, mitigando ataques de confusion de dependencias.