This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Piglet Runtime: AI Runtime Sandbox

Pigsty Lightweight Runtime, AI Coding sandbox, spin up your cloud coding environment with one click

    Pigsty Lightweight Runtime, AI Coding Sandbox

    PIGLET is a lightweight runtime environment based on Pigsty, designed for AI Web Coding cloud sandbox. It integrates PostgreSQL database, JuiceFS distributed storage, Code Server, JupyterLab, Claude Code, Codex CLI and more into one, enabling zero-friction workflow from “prompting code” to “production deployment”.


    Key Features

    FeatureDescription
    🤖 AI CodingPre-installed Claude Code, Codex CLI, OpenCode, VS Code, Jupyter full stack, Python/Go/Node.js dev env ready
    🐘 Data CapablePostgreSQL 18 + 531 extensions, vector/timeseries/geo/graph/analytics, add Supabase for complex apps
    💾 Shared StorageJuiceFS stores working directory in database, multi-agent/multi-user collaboration, files never lost, rollback to any point
    ⏱️ Time MachineDatabase PITR + filesystem snapshot sync, messed up? One-click restore to any point in time, keep db and filesystem consistent!
    🔀 Instant CloneCoW sub-second Fork Large Database, fork existing instances/clusters, no extra storage, rebuild anytime, tinker freely!
    🌐 One-Click DeployBuilt-in Nginx handles domains, certs, proxy, static/dynamic sites, from prompt to production in one step!
    📊 Full-Stack MonitoringVictoriaMetrics + Grafana panoramic dashboards, Claude Code observability included, all details at your fingertips!
    🇨🇳 China AccessibleGlobal CDN + mirrors, one config for CC + GLM-5.2 domestic models, legal and compliant!

    Quick Start

    Prepare a node with SSH access, running a compatible Linux distro, execute with an admin user having passwordless ssh and sudo:

    curl -fsSL https://repo.pigsty.io/get | bash; cd ~/pigsty
    ./configure -c vibe -g # Use vibe mode, generate random passwords!
    ./deploy.yml           # Deploy infrastructure and PostgreSQL
    ./juice.yml            # Deploy JuiceFS filesystem
    ./vibe.yml             # Deploy Claude Code, Codex CLI, Code-Server, JupyterLab
    

    After installation, access the sandbox homepage via IP: http://<ip>. Assuming your IP is 10.10.10.10:

    ToolDescription
    Homepagehttp://10.10.10.10/
    Code Serverhttp://10.10.10.10/code
    Jupyter Labhttp://10.10.10.10/jupyter
    Grafana Dashboardhttp://10.10.10.10/ui
    Claude Monitorhttp://10.10.10.10/ui/d/claude-code

    Tip: If deploying on a public cloud server, check Security Best Practices, change passwords (configure -g), and enable firewall.


    VIBE Components

    vibe.yml splits the browser IDE, notebook, AI CLIs, and Node.js runtime into independently switchable components:

    ComponentDefaultDescriptionRun Separately
    Code Servercode_enabled: trueBrowser-based VS Code, mounted at /code by default./vibe.yml -t code
    JupyterLabjupyter_enabled: trueNotebook and interactive terminal; the role defaults to disabled, while conf/vibe.yml explicitly enables it for the sandbox template./vibe.yml -t jupyter
    Node.jsnodejs_enabled: trueRuntime required by AI CLIs; installed on demand when Claude/Codex is enabled, and uses npmmirror for npm by default when region=china./vibe.yml -t nodejs
    Claude Codeclaude_enabled: trueInstalls @anthropic-ai/claude-code, renders ~/.claude.json and ~/.claude/settings.json, and enables monitoring by default./vibe.yml -t claude
    Codex CLIcodex_enabled: trueOnly runs npm install -g @openai/codex; it does not manage Codex config or integrate Codex into VIBE observability./vibe.yml -t codex
    Extra npmnpm_packages: []Installs additional global npm packages only; Claude and Codex are installed by their own tasks./vibe.yml -t nodejs_pkg

    If you do not need a component, set the matching *_enabled: false in pigsty.yml, or temporarily pass switches such as ./vibe.yml -e codex_enabled=false.


    Start AI Coding

    By default /fs is the shared directory stored in PostgreSQL, also the default home for VS Code and Jupyter. vibe renders the AGENTS.md environment guide there and creates a CLAUDE.md -> AGENTS.md symlink. This directory is the recommended place for Vibe Coding.

    You can ssh to the server then cd /fs, and normally start the corresponding CLI with claude or codex. The preconfigured x alias starts Codex YOLO mode, while xx starts Claude YOLO mode; use them carefully around real data. You can also start Claude Code from the Code Server or Jupyter terminal, or through VS Code / Jupyter Claude plugins.

    Claude here has logs and monitoring metrics integrated with Grafana dashboards, so you can monitor Claude’s running status through Grafana. Codex CLI is package-only in VIBE: the CLI package is installed by default, while login, provider setup, and config files are still managed by Codex itself.


    Using Other Models

    To make Claude Code use other models, such as GLM-5.2 that does not require overseas network access in China, modify pigsty.yml during installation. Find the claude_env section at the bottom and add Anthropic-compatible endpoint variables as needed:

    claude_env:
      ANTHROPIC_BASE_URL: https://open.bigmodel.cn/api/anthropic
      ANTHROPIC_API_URL: https://open.bigmodel.cn/api/anthropic
      ANTHROPIC_AUTH_TOKEN: your_api_service_token
      ANTHROPIC_DEFAULT_OPUS_MODEL: "glm-5.2[1m]"
      ANTHROPIC_DEFAULT_SONNET_MODEL: "glm-5.2[1m]"
      ANTHROPIC_DEFAULT_HAIKU_MODEL: "glm-4.7"
      CLAUDE_CODE_AUTO_COMPACT_WINDOW: "1000000"
    

    Then re-run ./vibe.yml -t claude. This only affects Claude Code; Codex CLI account and provider config are not managed by VIBE.

    Claude Code Observability

    To integrate Claude Code metrics and logs from other environments into the PIGLET monitoring system, configure environment variables to send OTEL events to the VictoriaMetrics / VictoriaLogs OTEL endpoints.

    # Claude Code OTEL Configuration
    export CLAUDE_CODE_ENABLE_TELEMETRY=1             # Enable monitoring
    export OTEL_METRICS_EXPORTER=otlp
    export OTEL_LOGS_EXPORTER=otlp
    export OTEL_LOG_USER_PROMPTS=1                    # Explicitly enable prompt-content logging when needed
    export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
    export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
    export OTEL_RESOURCE_ATTRIBUTES="ip=10.10.10.20,job=claude"  # Add your own labels
    export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://10.10.10.10:8428/opentelemetry/v1/metrics     # Metrics endpoint, VictoriaMetrics
    export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://10.10.10.10:9428/insert/opentelemetry/v1/logs    # Logs endpoint, VictoriaLogs
    export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative