Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

3.9 KB
Raw Blame
name: ${COMPOSE_PROJECT_NAME:-openmausbot}
services:
  omb:
    # Collects exited browser processes; Chrome's shared memory as on the
    # desktop containers (docs/browser-packaging.md, "Process hygiene").
    init: true
    shm_size: 512m
    build:
      context: ./deploy/local
      args:
        BASE_IMAGE: ${OMB_BASE_IMAGE:-ghcr.io/milind-soni/openmausbot:latest}
        ENGINES: ${ENGINES-@anthropic-ai/claude-code @openai/codex}
    image: ${OMB_LOCAL_IMAGE:-openmausbot-local:latest}
    restart: unless-stopped
    volumes:
      - data:/data
      - edge:/run/openmausbot
    environment:
      OMB_PORT: "8799"
      OMB_WEBHOOK_PORT: "8800"
      # Caddy, in its own container, reaches the server over these (deploy/local/Caddyfile). A request on a socket is
      # never a local one. Caddy does not share the server's network: a server restarted on its own would come back
      # in a new one and leave Caddy, and the port, behind in the old one.
      OMB_TUNNEL_SOCKET: /run/openmausbot/http.sock
      OMB_WEBHOOK_SOCKET: /run/openmausbot/hooks.sock
      # The name the desktop app shows for this server (a container's own hostname is a random id).
      OMB_SERVER_NAME: ${OMB_SERVER_NAME:-mausbot-docker}
      OMB_PUBLIC_URL: ${OMB_PUBLIC_URL:-http://localhost:${OMB_HTTP_PORT:-8080}}
      OMB_WEBHOOK_PUBLIC_URL: ${OMB_WEBHOOK_PUBLIC_URL:-${OMB_PUBLIC_URL:-http://localhost:${OMB_HTTP_PORT:-8080}}}
      # "1": phones pair by QR through MausBot Relay (docs/phone-relay-server.md). Sign the
      # container in once first: docker compose exec omb openmausbot login --relay
      OMB_PHONE_RELAY: ${OMB_PHONE_RELAY:-}
      # The licence; a license.key in the data folder (/data/.openmausbot) is read too, and the newer one wins.
      OMB_LICENSE_KEY: ${OMB_LICENSE_KEY:-}
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://127.0.0.1:8799/api/health | grep -q openmausbot"]
      interval: 30s
      timeout: 5s
      start_period: 30s
      retries: 5
  caddy:
    image: ${CADDY_IMAGE:-caddy:2}
    restart: unless-stopped
    ports:
      - "${OMB_BIND_ADDRESS:-127.0.0.1}:${OMB_HTTP_PORT:-8080}:80"
    environment:
      OMB_HTTPS_HOST: ${OMB_HTTPS_HOST:-}
      OMB_BIND_ADDRESS: ${OMB_BIND_ADDRESS:-127.0.0.1}
      OMB_TRUSTED_PROXY_CIDRS: ${OMB_TRUSTED_PROXY_CIDRS:-}
    command:
      - /bin/sh
      - -ec
      - |
        # HTTPS is claimed by the peer that terminates TLS, so a bind address
        # that others can reach has to name that peer.
        if [ -n "$$OMB_HTTPS_HOST" ] && [ "$$OMB_BIND_ADDRESS" != "127.0.0.1" ] && [ -z "$$OMB_TRUSTED_PROXY_CIDRS" ]; then
          echo "OMB_HTTPS_HOST with OMB_BIND_ADDRESS=$$OMB_BIND_ADDRESS requires OMB_TRUSTED_PROXY_CIDRS naming the TLS terminator; forward HTTPS through that terminator." >&2
          exit 1
        fi
        # An empty list lets any peer claim the HTTPS hostname, which only the
        # loopback bind keeps to the host itself.
        export OMB_TRUSTED_PROXY_CIDRS="$${OMB_TRUSTED_PROXY_CIDRS:-0.0.0.0/0 ::/0}"
        exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
    # Started with the server, not after it is healthy: Caddy reaches it over the socket
    # whenever it answers, so `up` never waits on the server's health, and HTTPS is back
    # as soon as a restarted server is.
    depends_on:
      omb:
        condition: service_started
    volumes:
      - ./deploy/local/Caddyfile:/etc/caddy/Caddyfile:ro
      - edge:/run/openmausbot
      - caddy_data:/data
      - caddy_config:/config
volumes:
  data:
    external: ${OMB_DATA_EXTERNAL:-false}
    name: ${OMB_DATA_VOLUME:-${COMPOSE_PROJECT_NAME:-openmausbot}_data}
  # The two sockets: in memory, made afresh by the server at each start. Not under /data, which every bot's sandbox
  # sees; the sandbox has its own /run.
  edge:
    driver_opts:
      type: tmpfs
      device: tmpfs
      o: mode=1777,size=1m
  caddy_data:
  caddy_config: