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.

4.4 KB
Raw Blame
# Cloud Build -> Cloud Run for the chat gateway worker (workers/agent-gateway).
#
# Submit from the REPO ROOT (the Dockerfile builds the root install and copies
# api/, which the gateway core lives in):
#
#   gcloud builds submit --config workers/agent-gateway/cloudbuild.yaml . \
#     --region us-central1 --project aerial-vehicle-466722-p5 \
#     --substitutions=SHORT_SHA=manual$(date +%s)
#
# SHORT_SHA is only set for trigger-driven builds; a manual submit must pass it
# or the image tag is empty and the push fails.
#
# The service's environment is derived from the live three-ws-api service on
# every deploy (scripts/deploy-env.mjs): literals by value, credentials by
# Secret Manager reference, platform treasury and payer signers left out. A
# variable the gateway needs (DISCORD_BOT_TOKEN, DISCORD_APP_ID,
# DISCORD_PUBLIC_KEY, TELEGRAM_BOT_TOKEN) therefore belongs on three-ws-api,
# which needs it too for the receivers and the settings page, and reaches the
# worker on its next deploy. Gateway tuning knobs ride in as substitutions.
#
# Always on: --no-cpu-throttling keeps the drain loop and the Discord gateway
# connection running between requests, and min-instances 1 keeps one worker up.
# The VPC connector matches three-ws-api: the rate limiter's Redis endpoint is a
# private address. Ingress is closed (no unauthenticated invokes); nothing calls
# this service over HTTP except Cloud Run's own probes.
#
# Builds run as the pinned three-ws-build service account (the project's
# default compute service account was deleted) and the service runs as three-ws.

serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]

substitutions:
  _REGION: us-central1
  _SERVICE: agent-gateway
  _REPO: workers
  _SOURCE_SERVICE: three-ws-api
  _MIN_INSTANCES: "1"
  _MAX_INSTANCES: "1"
  _CONCURRENCY: "8"
  _MAX_ATTEMPTS: "5"

steps:
  - id: pull-cache
    name: gcr.io/cloud-builders/docker
    entrypoint: bash
    args: ['-c', 'docker pull ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest || exit 0']

  - id: build
    name: gcr.io/cloud-builders/docker
    env: ['DOCKER_BUILDKIT=1']
    args:
      - build
      - --file
      - workers/agent-gateway/Dockerfile
      - --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
      - --build-arg
      - BUILDKIT_INLINE_CACHE=1
      - .
    timeout: 1800s

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

  - id: read-api-env
    name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
    entrypoint: bash
    args: ['-c', 'gcloud run services describe ${_SOURCE_SERVICE} --region=${_REGION} --project=$PROJECT_ID --format=json > /workspace/api-service.json']

  - id: derive-env
    name: node:24-slim
    entrypoint: node
    args:
      - workers/agent-gateway/scripts/deploy-env.mjs
      - /workspace/api-service.json
      - /workspace/gateway-env.yaml
      - /workspace/gateway-secrets.txt
      - --set
      - GATEWAY_CONCURRENCY=${_CONCURRENCY}
      - --set
      - GATEWAY_MAX_ATTEMPTS=${_MAX_ATTEMPTS}

  - id: deploy
    name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
    entrypoint: bash
    args:
      - -c
      - >-
        gcloud run deploy ${_SERVICE}
        --image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
        --region=${_REGION}
        --project=$PROJECT_ID
        --platform=managed
        --service-account=three-ws@$PROJECT_ID.iam.gserviceaccount.com
        --no-allow-unauthenticated
        --no-cpu-throttling
        --cpu=1
        --memory=2Gi
        --min-instances=${_MIN_INSTANCES}
        --max-instances=${_MAX_INSTANCES}
        --vpc-connector=three-ws-vpc
        --vpc-egress=private-ranges-only
        --env-vars-file=/workspace/gateway-env.yaml
        --set-secrets="$$(cat /workspace/gateway-secrets.txt)"
        && rm -f /workspace/api-service.json /workspace/gateway-env.yaml /workspace/gateway-secrets.txt

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

timeout: 2700s