|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# ───────────────────────────────────────────────────────────────────────────── |
| 3 | +# The AI OS — containerised. |
| 4 | +# |
| 5 | +# Nine open-source AI projects across three runtimes (Python/uv, Node/pnpm, Bun) |
| 6 | +# in one image, driven by `aios`. |
| 7 | +# |
| 8 | +# docker compose up -d then open http://localhost:8787 |
| 9 | +# |
| 10 | +# Why a container is the *right* place to run this: The AI OS gives every agent |
| 11 | +# full control of the machine it runs on — shell, filesystem, network. On your |
| 12 | +# laptop that means your laptop. Here it means this container, which is a blast |
| 13 | +# radius you can delete. Guardrails and the hub token still apply inside. |
| 14 | +# ───────────────────────────────────────────────────────────────────────────── |
| 15 | + |
| 16 | +# ---------- stage 1: toolchains --------------------------------------------- |
| 17 | +FROM python:3.12-slim-bookworm AS base |
| 18 | + |
| 19 | +ENV DEBIAN_FRONTEND=noninteractive \ |
| 20 | + PYTHONUNBUFFERED=1 \ |
| 21 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 22 | + NODE_MAJOR=22 \ |
| 23 | + PNPM_HOME=/usr/local/pnpm \ |
| 24 | + BUN_INSTALL=/usr/local/bun \ |
| 25 | + PATH=/usr/local/pnpm:/usr/local/bun/bin:/root/.local/bin:$PATH |
| 26 | + |
| 27 | +# Node 22 (openclaw + Next.js need >=20), plus the build deps native modules want. |
| 28 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 29 | + ca-certificates curl git unzip xz-utils ripgrep procps tini \ |
| 30 | + build-essential python3-dev \ |
| 31 | + && curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \ |
| 32 | + && apt-get install -y --no-install-recommends nodejs \ |
| 33 | + && npm install -g pnpm@9 \ |
| 34 | + && curl -fsSL https://bun.sh/install | bash \ |
| 35 | + && curl -LsSf https://astral.sh/uv/install.sh | sh \ |
| 36 | + && apt-get purge -y --auto-remove \ |
| 37 | + && rm -rf /var/lib/apt/lists/* /tmp/* |
| 38 | + |
| 39 | +# Claude Code CLI — powers the claude-code service (subscription auth, no API key). |
| 40 | +RUN npm install -g @anthropic-ai/claude-code || \ |
| 41 | + echo "claude CLI unavailable at build time; install later with: npm i -g @anthropic-ai/claude-code" |
| 42 | + |
| 43 | +# yt-dlp powers YouTube transcripts (the caption endpoint needs a PO token). |
| 44 | +RUN pip install --no-cache-dir --upgrade yt-dlp |
| 45 | + |
| 46 | +# ---------- stage 2: runtime ------------------------------------------------ |
| 47 | +FROM base AS runtime |
| 48 | +WORKDIR /aios |
| 49 | + |
| 50 | +LABEL org.opencontainers.image.title="The AI OS" \ |
| 51 | + org.opencontainers.image.description="Nine open-source AI projects. One operating system." \ |
| 52 | + org.opencontainers.image.source="https://github.com/ZDStudios/AIOS" \ |
| 53 | + org.opencontainers.image.licenses="MIT" |
| 54 | + |
| 55 | +COPY . /aios |
| 56 | + |
| 57 | +# `aios setup` does the installing rather than a hand-written RUN, because it |
| 58 | +# already encodes every per-project workaround: --ignore-scripts for the native |
| 59 | +# postinstalls that need VS Build Tools, NODE_OPTIONS heap sizing for openclaw's |
| 60 | +# build, and uv sync for the Python projects. Installing from package.json alone |
| 61 | +# silently produces empty node_modules — opencode and openclaw are workspace |
| 62 | +# monorepos and need their full source present to resolve. |
| 63 | +RUN set -eux; \ |
| 64 | + cp -n aios.config.example.yaml aios.config.yaml 2>/dev/null || true; \ |
| 65 | + chmod +x aios docker/entrypoint.sh 2>/dev/null || true; \ |
| 66 | + mkdir -p /aios/.aios; \ |
| 67 | + python aios.py setup --non-interactive --skip-keys --skip-tools --skip-wire \ |
| 68 | + || echo "setup reported warnings — see 'docker compose exec aios aios doctor'"; \ |
| 69 | + # Same layer as the install, or the image keeps the deleted bytes anyway. |
| 70 | + # pnpm hardlinks node_modules into its content-addressable store, so dropping |
| 71 | + # the store frees ~4.7GB while the linked files stay intact (verified). |
| 72 | + rm -rf /usr/local/pnpm/store /root/.cache /root/.npm /tmp/* /var/tmp/*; \ |
| 73 | + find /aios -type d -name ".git" -prune -exec rm -rf {} + 2>/dev/null || true; \ |
| 74 | + apt-get purge -y --auto-remove build-essential python3-dev 2>/dev/null || true; \ |
| 75 | + rm -rf /var/lib/apt/lists/* |
| 76 | + |
| 77 | +# Login shells (docker exec ... bash) re-read /etc/profile and would otherwise |
| 78 | +# lose the toolchain PATH baked into ENV. |
| 79 | +RUN printf 'export PATH=/usr/local/pnpm:/usr/local/bun/bin:/root/.local/bin:$PATH\n' \ |
| 80 | + > /etc/profile.d/aios-path.sh |
| 81 | + |
| 82 | +ENV AIOS_ROOT=/aios \ |
| 83 | + AIOS_HUB_HOST=0.0.0.0 \ |
| 84 | + AIOS_IN_DOCKER=1 \ |
| 85 | + AIOS_NO_UPDATE_CHECK=1 |
| 86 | + |
| 87 | +# 8787 hub · 4096 opencode · 9119 hermes · 18789 openclaw |
| 88 | +# 4788 crewai · 8000 claude-code · 8791/8792 embed proxies |
| 89 | +EXPOSE 8787 4096 9119 18789 4788 8000 8791 8792 |
| 90 | + |
| 91 | +HEALTHCHECK --interval=30s --timeout=5s --start-period=180s --retries=5 \ |
| 92 | + CMD curl -fsS http://127.0.0.1:8787/health || exit 1 |
| 93 | + |
| 94 | +# tini reaps the process trees aios spawns, so stopping the container doesn't |
| 95 | +# strand bun/node/uv children as zombies. |
| 96 | +ENTRYPOINT ["/usr/bin/tini", "--", "/aios/docker/entrypoint.sh"] |
| 97 | +CMD ["start"] |
0 commit comments