|
| 1 | +# Agent Runtime Container for AI Agent Playground |
| 2 | +# |
| 3 | +# Ubuntu 24.04 LTS with: |
| 4 | +# - Node.js 22.x |
| 5 | +# - Playwright with browser binaries (Chromium, Firefox, WebKit) |
| 6 | +# - @predicatesystems/runtime SDK |
| 7 | +# - Python 3.12 (optional, for webbench agents) |
| 8 | +# - Non-root user: agentuser |
| 9 | +# |
| 10 | +# Usage: |
| 11 | +# docker build -f Dockerfile.playground -t agent-runtime . |
| 12 | +# docker run -it --rm agent-runtime bash |
| 13 | + |
| 14 | +FROM ubuntu:24.04 |
| 15 | + |
| 16 | +# Prevent interactive prompts during package installation |
| 17 | +ENV DEBIAN_FRONTEND=noninteractive |
| 18 | + |
| 19 | +# Install base dependencies and Node.js 22.x |
| 20 | +RUN apt-get update && apt-get install -y \ |
| 21 | + curl \ |
| 22 | + ca-certificates \ |
| 23 | + gnupg \ |
| 24 | + git \ |
| 25 | + jq \ |
| 26 | + # Python 3.12 for webbench agents (optional) |
| 27 | + python3.12 \ |
| 28 | + python3-pip \ |
| 29 | + python3-venv \ |
| 30 | + && rm -rf /var/lib/apt/lists/* |
| 31 | + |
| 32 | +# Install Node.js 22.x from NodeSource |
| 33 | +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ |
| 34 | + && apt-get install -y nodejs \ |
| 35 | + && rm -rf /var/lib/apt/lists/* |
| 36 | + |
| 37 | +# Install Playwright system dependencies |
| 38 | +# These are required for Chromium, Firefox, and WebKit browsers |
| 39 | +RUN apt-get update && apt-get install -y \ |
| 40 | + # Core libraries |
| 41 | + libnss3 \ |
| 42 | + libnspr4 \ |
| 43 | + libatk1.0-0 \ |
| 44 | + libatk-bridge2.0-0 \ |
| 45 | + libcups2 \ |
| 46 | + libdrm2 \ |
| 47 | + libxkbcommon0 \ |
| 48 | + libxcomposite1 \ |
| 49 | + libxdamage1 \ |
| 50 | + libxfixes3 \ |
| 51 | + libxrandr2 \ |
| 52 | + libgbm1 \ |
| 53 | + libasound2t64 \ |
| 54 | + libpango-1.0-0 \ |
| 55 | + libcairo2 \ |
| 56 | + # Firefox dependencies |
| 57 | + libdbus-glib-1-2 \ |
| 58 | + # WebKit dependencies |
| 59 | + libwoff1 \ |
| 60 | + libharfbuzz-icu0 \ |
| 61 | + libgstreamer-plugins-base1.0-0 \ |
| 62 | + libgstreamer-gl1.0-0 \ |
| 63 | + libgstreamer-plugins-bad1.0-0 \ |
| 64 | + libenchant-2-2 \ |
| 65 | + libsecret-1-0 \ |
| 66 | + libhyphen0 \ |
| 67 | + libmanette-0.2-0 \ |
| 68 | + libgles2 \ |
| 69 | + # Fonts for rendering |
| 70 | + fonts-noto-color-emoji \ |
| 71 | + fonts-noto-cjk \ |
| 72 | + fonts-freefont-ttf \ |
| 73 | + # X11 virtual framebuffer for headless |
| 74 | + xvfb \ |
| 75 | + && rm -rf /var/lib/apt/lists/* |
| 76 | + |
| 77 | +# Create non-root user for security |
| 78 | +# This is required for Playwright and Claude Code's --dangerously-skip-permissions |
| 79 | +# Use UID 1001 to avoid conflict with existing ubuntu user (UID 1000) |
| 80 | +RUN useradd -m -s /bin/bash -u 1001 agentuser |
| 81 | + |
| 82 | +# Create directories with proper permissions |
| 83 | +RUN mkdir -p /app /data /workspace \ |
| 84 | + && chown -R agentuser:agentuser /app /data /workspace |
| 85 | + |
| 86 | +WORKDIR /app |
| 87 | + |
| 88 | +# Copy SDK source for building (as root for npm install) |
| 89 | +COPY --chown=agentuser:agentuser package*.json ./ |
| 90 | +COPY --chown=agentuser:agentuser tsconfig.json ./ |
| 91 | +COPY --chown=agentuser:agentuser src/ ./src/ |
| 92 | + |
| 93 | +# Install dependencies and build SDK |
| 94 | +RUN npm install && npm run build |
| 95 | + |
| 96 | +# Install Playwright CLI and browsers as agentuser |
| 97 | +USER agentuser |
| 98 | + |
| 99 | +# Set Playwright browser path |
| 100 | +ENV PLAYWRIGHT_BROWSERS_PATH=/home/agentuser/.cache/ms-playwright |
| 101 | + |
| 102 | +# Install Playwright browsers (Chromium only by default for faster builds) |
| 103 | +# Add firefox and webkit if needed: npx playwright install firefox webkit |
| 104 | +RUN npx playwright install chromium |
| 105 | + |
| 106 | +# Switch back to root temporarily to set up remaining items |
| 107 | +USER root |
| 108 | + |
| 109 | +# Copy demo workspace files |
| 110 | +COPY --chown=agentuser:agentuser examples/real-openclaw-demo/workspace/ /workspace/ |
| 111 | + |
| 112 | +# Copy agent source files (market research agent) |
| 113 | +COPY --chown=agentuser:agentuser examples/real-openclaw-demo/src/ /app/examples/real-openclaw-demo/src/ |
| 114 | + |
| 115 | +# Copy SecureClaw hook script (if using Claude Code integration) |
| 116 | +COPY --chown=agentuser:agentuser examples/real-openclaw-demo/secureclaw-hook.sh /app/secureclaw-hook.sh |
| 117 | +RUN chmod +x /app/secureclaw-hook.sh |
| 118 | + |
| 119 | +# Install tsx for running TypeScript directly |
| 120 | +RUN npm install -g tsx |
| 121 | + |
| 122 | +# Create data directory with proper permissions |
| 123 | +RUN mkdir -p /data && chown -R agentuser:agentuser /data |
| 124 | + |
| 125 | +# Switch to non-root user for execution |
| 126 | +USER agentuser |
| 127 | + |
| 128 | +# Set working directory |
| 129 | +WORKDIR /app |
| 130 | + |
| 131 | +# Environment variables |
| 132 | +ENV HOME=/home/agentuser |
| 133 | +ENV NODE_ENV=production |
| 134 | +ENV PREDICATE_SIDECAR_URL=http://predicate-sidecar:8000 |
| 135 | +ENV SECURECLAW_PRINCIPAL=agent:market-research |
| 136 | +ENV SECURECLAW_VERBOSE=true |
| 137 | + |
| 138 | +# Health check |
| 139 | +HEALTHCHECK --interval=10s --timeout=5s --retries=3 \ |
| 140 | + CMD node -e "console.log('ok')" || exit 1 |
| 141 | + |
| 142 | +# Default: run the market research agent |
| 143 | +CMD ["npx", "tsx", "/app/examples/real-openclaw-demo/src/market-research-agent.ts"] |
0 commit comments