Skip to content

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.

3.2 KB
Raw Blame
# Cloud Build to Cloud Run for the on-demand caster pool (workers/agent-screen-pool).
#
# Background daemon deployed as a SERVICE: the reconcile loop runs continuously
# and index.js binds a tiny liveness endpoint on $PORT so the Cloud Run startup
# probe passes. Deployed with --no-cpu-throttling and --min-instances=1 so the
# loop keeps ticking between probes, and --max-instances=1 because two instances
# would both claim the same watched agents and double-push frames.
#
# Build context is THIS directory (the Dockerfile copies only worker files), so
# submit it with the directory as the source:
#
#   gcloud builds submit workers/agent-screen-pool \
#     --config workers/agent-screen-pool/cloudbuild.yaml \
#     --region us-central1 --project aerial-vehicle-466722-p5
#
# The shared secret already exists in Secret Manager as `screen-worker-secret`
# (created 2026-08-11, three-ws@ granted secretAccessor). The API side reads the
# same value from env SCREEN_WORKER_SECRET; both must match or the pool sees a
# 401 on every poll.
#
# Builds run as the pinned three-ws-build service account: the project's default
# compute service account was deleted, so an unpinned submit fails with
# "Unknown service account".
serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]

substitutions:
  _REGION: us-central1
  _SERVICE: agent-screen-pool
  _REPO: workers
  _BASE_URL: https://three.ws
  # Concurrent Chromium casts. Keep in sync with the API's SCREEN_POOL_MAX, which
  # is what a viewer's "queued, #N in line" position is computed against.
  _MAX_BROWSERS: "6"

steps:
  - id: build
    name: gcr.io/cloud-builders/docker
    args:
      - build
      - --tag
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
      - --tag
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest
      - --cache-from
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest
      - .
    timeout: 1200s

  - id: push
    name: gcr.io/cloud-builders/docker
    args:
      - push
      - --all-tags
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}

  - id: deploy
    name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
    entrypoint: gcloud
    args:
      - run
      - deploy
      - ${_SERVICE}
      - --image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
      - --region=${_REGION}
      - --platform=managed
      - --no-cpu-throttling
      - --cpu=2
      # Budget ~350 MB per concurrent page plus the browser itself; 4Gi covers
      # _MAX_BROWSERS=6 with headroom. Raise both together if the cap goes up.
      - --memory=4Gi
      - --min-instances=1
      - --max-instances=1
      - --no-allow-unauthenticated
      - --service-account=three-ws@$PROJECT_ID.iam.gserviceaccount.com
      - --set-env-vars=NODE_ENV=production,BASE_URL=${_BASE_URL},MAX_BROWSERS=${_MAX_BROWSERS}
      - --set-secrets=SCREEN_WORKER_SECRET=screen-worker-secret:latest

images:
  - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
  - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest

options:
  machineType: E2_HIGHCPU_8
  logging: CLOUD_LOGGING_ONLY