|
| 1 | +# Framework-agnostic CopilotKit Intelligence activation overlay. |
| 2 | +# |
| 3 | +# Starts postgres, redis, and the all-in-one intelligence composite |
| 4 | +# container (runs app-api, realtime-gateway, thread-culler, and the |
| 5 | +# db-migrations oneshot internally under s6-overlay). |
| 6 | +# |
| 7 | +# Usage: |
| 8 | +# docker compose up -d --wait |
| 9 | +# |
| 10 | +# Then start the app services on the host: |
| 11 | +# npm run dev |
| 12 | + |
| 13 | +name: copilotkit-intelligence |
| 14 | + |
| 15 | +services: |
| 16 | + # --------------------------------------------------------------------------- |
| 17 | + # Infrastructure |
| 18 | + # --------------------------------------------------------------------------- |
| 19 | + |
| 20 | + postgres: |
| 21 | + image: postgres:16-alpine |
| 22 | + ports: |
| 23 | + - "${POSTGRES_HOST_PORT:-5432}:5432" |
| 24 | + environment: |
| 25 | + POSTGRES_USER: intelligence |
| 26 | + POSTGRES_PASSWORD: intelligence |
| 27 | + POSTGRES_DB: postgres |
| 28 | + volumes: |
| 29 | + - postgres-data:/var/lib/postgresql/data |
| 30 | + - ./docker/init-db:/docker-entrypoint-initdb.d:ro |
| 31 | + healthcheck: |
| 32 | + test: ["CMD-SHELL", "pg_isready -U intelligence -d postgres"] |
| 33 | + interval: 5s |
| 34 | + timeout: 3s |
| 35 | + retries: 5 |
| 36 | + restart: unless-stopped |
| 37 | + networks: |
| 38 | + - intelligence |
| 39 | + |
| 40 | + redis: |
| 41 | + image: redis:7-alpine |
| 42 | + ports: |
| 43 | + - "${REDIS_HOST_PORT:-6379}:6379" |
| 44 | + volumes: |
| 45 | + - redis-data:/data |
| 46 | + healthcheck: |
| 47 | + test: ["CMD", "redis-cli", "ping"] |
| 48 | + interval: 5s |
| 49 | + timeout: 3s |
| 50 | + retries: 5 |
| 51 | + restart: unless-stopped |
| 52 | + networks: |
| 53 | + - intelligence |
| 54 | + |
| 55 | + # --------------------------------------------------------------------------- |
| 56 | + # Intelligence composite (app-api + realtime-gateway + thread-culler + |
| 57 | + # db-migrations, all in one container under s6-overlay) |
| 58 | + # --------------------------------------------------------------------------- |
| 59 | + |
| 60 | + intelligence: |
| 61 | + image: ghcr.io/copilotkit/intelligence/composite:0.2.0 |
| 62 | + ports: |
| 63 | + - "${APP_API_HOST_PORT:-4201}:4201" |
| 64 | + - "${REALTIME_GATEWAY_HOST_PORT:-4401}:4401" |
| 65 | + environment: |
| 66 | + DATABASE_URL: postgresql://intelligence:intelligence@postgres:5432/intelligence_app |
| 67 | + REDIS_URL: redis://redis:6379 |
| 68 | + AUTH_SECRET: local-dev-secret-must-be-at-least-32-chars |
| 69 | + RUNNER_AUTH_SECRET: dev-runner-secret |
| 70 | + SECRET_KEY_BASE: local-realtime-gateway-secret-key-base-at-least-64-bytes-long-for-dev |
| 71 | + DEFAULT_ORGANIZATION_ID: casa-de-erlang |
| 72 | + # Local dev: the web app runs on http://localhost:<port>, not the gateway's |
| 73 | + # configured https://localhost, so disable Phoenix origin checking on the |
| 74 | + # realtime-gateway websocket (otherwise client WS connects get a 403). |
| 75 | + CHECK_ORIGIN: "false" |
| 76 | + COPILOTKIT_LICENSE_TOKEN: "${COPILOTKIT_LICENSE_TOKEN:-}" |
| 77 | + THREAD_STALE_HOURS: "${THREAD_STALE_HOURS:-3}" |
| 78 | + THREAD_CULL_BATCH_SIZE: "${THREAD_CULL_BATCH_SIZE:-1000}" |
| 79 | + depends_on: |
| 80 | + postgres: |
| 81 | + condition: service_healthy |
| 82 | + redis: |
| 83 | + condition: service_healthy |
| 84 | + restart: unless-stopped |
| 85 | + networks: |
| 86 | + - intelligence |
| 87 | + |
| 88 | + # --------------------------------------------------------------------------- |
| 89 | + # Demo user provisioning (one-shot) |
| 90 | + # --------------------------------------------------------------------------- |
| 91 | + # Ensures the runtime's identifyUser id (COPILOTKIT_DEMO_USER_ID, default |
| 92 | + # "demo-user") exists in cpki.users so created threads can attach to it. |
| 93 | + # Idempotent; mirrors the two-row pattern the composite's startup seed uses: |
| 94 | + # a bare id (membership checks) plus a per-project scoped alias |
| 95 | + # "<projectId>_<userId>" (the threads_user_id_fkey target). Runs once after the |
| 96 | + # composite is healthy (schema + org/projects seeded), then exits. |
| 97 | + provision-user: |
| 98 | + image: postgres:16-alpine |
| 99 | + depends_on: |
| 100 | + intelligence: |
| 101 | + condition: service_healthy |
| 102 | + environment: |
| 103 | + PGPASSWORD: intelligence |
| 104 | + DEMO_USER_ID: "${COPILOTKIT_DEMO_USER_ID:-demo-user}" |
| 105 | + ORG_ID: "${COPILOTKIT_ORGANIZATION_ID:-casa-de-erlang}" |
| 106 | + entrypoint: ["sh", "-c"] |
| 107 | + command: |
| 108 | + - | |
| 109 | + psql -h postgres -U intelligence -d intelligence_app -v ON_ERROR_STOP=1 \ |
| 110 | + -c "INSERT INTO cpki.users (id, organization_id) VALUES ('$$DEMO_USER_ID', '$$ORG_ID') ON CONFLICT (id) DO NOTHING;" \ |
| 111 | + -c "INSERT INTO cpki.users (id, organization_id) SELECT p.id || '_' || '$$DEMO_USER_ID', '$$ORG_ID' FROM cpki.projects p WHERE p.organization_id = '$$ORG_ID' AND p.deleted_at IS NULL ON CONFLICT (id) DO NOTHING;" |
| 112 | + restart: "no" |
| 113 | + networks: |
| 114 | + - intelligence |
| 115 | + |
| 116 | +volumes: |
| 117 | + postgres-data: |
| 118 | + redis-data: |
| 119 | + |
| 120 | +networks: |
| 121 | + intelligence: |
| 122 | + driver: bridge |
0 commit comments