Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
# syntax=docker/dockerfile:1.7-labs
# three.ws production image for Google Cloud Run.
# Runs server/index.mjs: the static frontend (dist/), the vercel.json route
# table, and every api/** handler with Vercel-parity routing. See
# server/README.md.
#
# Layering is cache-oriented (built via server/cloudbuild.yaml with BuildKit):
# manifests are copied alone so the `npm ci` layer survives source-only
# changes — the common case during the migration — cutting rebuilds from
# ~10 min to ~3. Dependency lifecycle scripts and the root postinstall (which
# builds the workspace SDKs from source) run after the full copy.
FROM node:24-slim
WORKDIR /app
# node-gyp toolchain: native deps (better-sqlite3, bigint bindings) have no
# Node 24 prebuilts, so `npm rebuild` compiles them from source.
#
# The lib*/fonts block is the shared-library runtime for headless chromium
# (@sparticuz/chromium-min downloads the binary to /tmp at first use, but it
# still links against system libs). Without it every avatar-thumbnail render
# on Cloud Run dies at launch with "libnspr4.so: cannot open shared object
# file" — see api/_lib/render-glb.js and api/cron/avatar-thumbnail-backfill.js.
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
libnspr4 libnss3 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 libcups2 \
libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
libgbm1 libasound2 libpango-1.0-0 libcairo2 libx11-6 libxcb1 libxext6 \
libexpat1 libglib2.0-0 fonts-liberation ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Same browser-download skips as the Vercel install command.
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \
PUPPETEER_SKIP_DOWNLOAD=1
# Pin npm to the version that PRODUCED package-lock.json. `FROM node:24-slim`
# floats, so its bundled npm changes under us without a single line of this repo
# changing, and `npm ci` refuses a lockfile whose tree a newer npm resolves
# differently. That is not hypothetical: on 2026-08-08 the base image moved from
# npm 11.9.0 to 11.17.0 and the production build died at this exact layer with
# "npm ci can only install packages when your package.json and package-lock.json
# are in sync, Missing: <dep> from lock file", against a lockfile nobody had
# touched. It reads like a dependency mistake and is really an unpinned
# toolchain. Verified both ways in the real base image: 11.17.0 fails on this
# context, 11.9.0 installs 3241 packages from it.
#
# When you regenerate package-lock.json with a newer npm, bump this to match.
ARG NPM_VERSION=11.9.0
RUN npm install -g npm@${NPM_VERSION}
# 1. Manifests only → cacheable `npm ci` layer. --parents preserves the
# workspace directory structure (requires the dockerfile 1.7-labs syntax).
COPY --parents package.json package-lock.json .npmrc* **/package.json /app/
RUN npm ci --ignore-scripts --no-audit --no-fund
# 2. Full source, then run the deferred lifecycle scripts: native/module
# install hooks (npm rebuild) and the root postinstall (SDK builds).
COPY . .
RUN npm rebuild && npm run postinstall
# 3. Shed devDependencies (playwright, vite, typescript, vitest, esbuild, jsdom…)
# now that the SDK builds above are done. The server and every api/** handler
# import only production deps at runtime — the frontend is pre-built into
# dist/ and served as static files — so nothing here is load-bearing at boot.
# --ignore-scripts: the lifecycle hooks already ran; prune must not re-trigger
# a workspace rebuild against a now-partial tree.
RUN npm prune --omit=dev --ignore-scripts --no-audit --no-fund
ENV NODE_ENV=production \
NODE_OPTIONS=--no-deprecation
# Drop root: Cloud Run has no reason to run this as uid 0. The node:24 base ships
# an unprivileged `node` user (uid 1000). The app never writes to /app at
# runtime — persona/ledger disk fallbacks target os.tmpdir(), and headless
# chromium downloads to /tmp — so a read-only, root-owned app tree is fine.
#
# But `COPY . .` preserves the build context's file modes, and a context built
# with an unusual umask (e.g. a git worktree on some CI filesystems yields dirs
# without the world-traverse bit) leaves directories the `node` user cannot enter
# — the container then dies at boot with a misleading `Cannot find module
# '/app/server/index.mjs'` (really EACCES on the path, surfaced as MODULE_NOT_FOUND).
# Normalize to world-readable + traversable before dropping privileges so the
# image boots regardless of the source umask. `a+rX` adds read to everything and
# the execute/traverse bit only to directories (and already-executable files).
#
# Only paths that actually lack those bits are touched. A blanket `chmod -R`
# changed the metadata of every file under /app, and overlayfs answers a chmod by
# copying the whole file up into the new layer: that one step took 527s of the
# docker build and shipped a 1.2 GB layer holding a second copy of the app,
# which also slowed every push and every Cloud Run image pull. The find below
# selects exactly the paths `chmod -R a+rX` would change (directories missing
# r-x for anyone, files missing read for anyone, files executable for some but
# not all), so the resulting modes are identical, and a normal context yields an
# empty layer.
RUN find /app \( \( -type d ! -perm -555 \) -o \( -type f \( ! -perm -444 -o \( -perm /111 ! -perm -111 \) \) \) \) -exec chmod a+rX {} +
USER node
EXPOSE 8080
CMD ["node", "server/index.mjs"]