diff --git a/README.md b/README.md index a21e9aafb57..9f73ae7ccab 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@

Ask DeepWiki - Set Up with Cursor + Set Up with Cursor

@@ -96,56 +96,7 @@ See the [MCP docs](https://docs.sim.ai/mcp/overview) for other clients and for s ## Self-hosting -**Requirements:** [Node.js 20+](https://nodejs.org/) and [Docker](https://www.docker.com/). - -`npx sim-setup` is an interactive wizard that creates a small `sim/` deployment directory, provisions the database, generates secrets, writes `.env`, connects a Chat API key, and starts the published Sim images with Docker Compose. It does not clone the repository. - -When it finishes, open [http://localhost:3000](http://localhost:3000). - -Inside a cloned Sim repository, run `bun run sim-setup` to unlock the source-only local development and Kubernetes modes. - -Reconfigure an optional capability without rerunning the full wizard: - -```bash -npx sim-setup config -npx sim-setup add email -npx sim-setup add storage -npx sim-setup add sandbox -npx sim-setup add jobs -npx sim-setup add knowledge -npx sim-setup add chat -npx sim-setup add llm -npx sim-setup add integration slack -``` - -`npx sim-setup config` detects the effective local-dev, Docker Compose, or current-context -Helm configuration and reports configured, missing, or invalid capabilities and OAuth -integrations without printing credential values. This is separate from `npx sim-setup status`, -which reports whether installed services are running and healthy. - -Manage your install from its directory: - -```bash -npx sim-setup start | stop | restart # bring your install up / down / cycle -npx sim-setup update # pull and apply Compose images -npx sim-setup status # what's installed and healthy -npx sim-setup logs # follow logs -npx sim-setup doctor # diagnose configuration problems -npx sim-setup down # remove containers (data kept) -npx sim-setup reset # archive .env and wipe managed data -``` - -The setup package detects how you're running and acts accordingly. Use `--dir ` to create or manage a deployment somewhere other than `./sim`. - -Sim also supports local models via [Ollama](https://ollama.ai), [vLLM](https://docs.vllm.ai/), and [LiteLLM](https://docs.litellm.ai/). See the [self-hosting docs](https://docs.sim.ai/self-hosting/docker) for details. - -## Chat API Keys - -Chat is a Sim-managed service. `npx sim-setup` connects a Chat API key for you — sign in when it opens your browser and the key is stored automatically. To view, create, or revoke keys later, go to [sim.ai/selfhost/settings/chat-keys](https://sim.ai/selfhost/settings/chat-keys). - -## Environment Variables - -See the [environment variables reference](https://docs.sim.ai/self-hosting/environment-variables) for the full list, or [`apps/sim/.env.example`](apps/sim/.env.example) for defaults. +`npx sim-setup` needs [Node.js 20+](https://nodejs.org/) and [Docker](https://www.docker.com/). It writes a `sim/` directory with the Compose file and a generated `.env`, connects a Chat API key, and starts Sim at [http://localhost:3000](http://localhost:3000). The [self-hosting guide](https://docs.sim.ai/platform/self-hosting) covers Kubernetes, configuration, local models, and upgrades. ## Tech Stack diff --git a/apps/docs/COPY_AUDIT.md b/apps/docs/COPY_AUDIT.md index 344e0f63e74..612af0680e8 100644 --- a/apps/docs/COPY_AUDIT.md +++ b/apps/docs/COPY_AUDIT.md @@ -502,7 +502,6 @@ Every row below represents a fully reviewed inventory entry. “Rewritten” inc | [platform/self-hosting/index.mdx](content/docs/platform/self-hosting/index.mdx) | rewritten | Replaced the drifting manual quick-start script with the setup wizard and Docker owner. Separated resource examples from enforced requirements and operational defaults. Placed key/file durability, public origin, email, scheduler, and verification before optional dependencies. Qualified enterprise behavior by billing mode and retained local embedding/remote image prerequisites. | Verified improvement. Reorders deployment choice, supported wizard, production hazards and dependencies; sizing becomes examples rather than user-count guarantees. Verified late fix: Quick start now places Bun and Node.js20 or newer before bunx sim-setup, alongside the preserved Docker and Compose2.24.0 prerequisites. Wizard output, manual setup links and production safeguards remain. Preserved: All deployment choices, resource examples, enterprise/org prerequisites, model/embedding/Chat/OAuth/remote dependencies and next steps retained. Removed raw5secret quickstart replaced by wizard plus full Docker manual setup. | | [platform/self-hosting/integrations-oauth.mdx](content/docs/platform/self-hosting/integrations-oauth.mdx) | rewritten | Created canonical Google, Microsoft, and Atlassian console setup sections for Search crosslinks. Preserved full Google Search member scopes/callbacks, all Microsoft resource scopes, full Confluence/Jira member scopes, API permissions/consent/distribution and reconnection distinctions. Added Intune, Ramp, and QuickBooks per-connection configuration; kept all prior provider exceptions/flows and hosted-only key constraints. Kept the complete GitHub App setup at its inbound anchor and removed both screenshots, retaining the correct six-permission table. Folded duplicate FAQ into setup/provider/troubleshooting sections and corrected Kubernetes secret modes. Used shared authored tabs with padded mixed content, wrapped prose, visible horizontal scrolling, and mobile touch targets. | Verified improvement. Adds complete Google/Microsoft/Atlassian member grants and distinction from Search service accounts; corrects secret-store deployment setup and scope-update/reconnect procedure. Verified late fix: GitHub App replacement now uses Credential Groups → Integrations → Update configurations. The migration affects existing provider options, preserves option IDs and retains all reconnect and secret handling consequences. Preserved: All original provider IDs/envcredentials/callbacks, GitHubAppsettings/readpermissions5variablesPEMrefresh/privateboundaries, Bitbucketexactpermissions,7providerextras, alternateInstagram/Shopify/Trelloflows, hostedkeycatalog/limits and nativeSlack requirements retained; current Ramp/Intune/QuickBooks added. Screenshots removed with full GitHub fields intact. | | [platform/self-hosting/kubernetes.mdx](content/docs/platform/self-hosting/kubernetes.mdx) | rewritten | Pinned published chart 1.11.8/appVersion v0.9.17 without claiming a live installation test or latest status. Replaced partial public-origin snippet with complete same-host/split-host routing, allowed origin and TLS Secret instructions. Separated inline, existing-Secret and ESO branches; documented env versus envDefaults and retained all core credentials. Labeled legacy ingress-nginx defaults and annotations honestly; did not choose/provision a controller or invent Gateway API support. Pinned cloud example source v0.9.17 and required review of certificate/IAM/storage/project placeholders; preserved database-name and key-loss upgrade caveats. Corrected cosign reference syntax and qualified registry mirroring of verification artifacts. | Verified improvement. Provides full3secretmode setup, working dual port-forward/public socket/TLS examples, same-releasepinnings, verification and safe retained-secret upgrades; scopes ingress retirement. Preserved: Every original OCI/classicrepo/cosign/attestation/cloud6domainoverride/ExternalDB/redis/migrations/cron/backupconversion/PVC consequence retained; code snippets now complete and pinned instead of abstract v1.2.3. | -| [platform/self-hosting/platforms.mdx](content/docs/platform/self-hosting/platforms.mdx) | rewritten | Converted unsupported Railway template guarantees into concrete verification steps and exposed five-minute cron limits. Replaced the production convenience-script recommendation with official Docker installation and plugin prerequisites. Clarified provider-specific cloud placeholders and extension availability/activation. Labeled external DATABASE_URL scope and explained production Compose overrides. | Verified improvement. Removes unsupported live-template assumptions and adds minute-scheduler gap, maintained ingress requirement and externalDSN Compose limitation. Preserved: Railway/VPS/EKS/AKS/GKE/database providers, pgvector requirement, TLS/ManagedCertificate, resource sizing and externalDatabase setup remain; Railway badge replaced by usable linked template. | | [platform/self-hosting/verify.mdx](content/docs/platform/self-hosting/verify.mdx) | rewritten | Preserved all 12 checks and doctor file/journal/live-probe limitations, then separated core and feature checks. Corrected cloud/local multipart thresholds and cross-replica proof claims. Added namespace-consistent commands, avoided printing a Redis credential, and checked actual job success rather than schedules alone. Preserved credential restore checks, uppercase INFO logging/no-op behavior, and upgrade subset. | Verified improvement. Replaces presence-only health guarantees with actual data/recipient/completion results and crosspod requirement; corrects multipart localvscloud thresholds. Preserved: All12checks/failureactions, doctor5groups/repairlimits/journal/skippedprobes, domains, infra/Composecommands, loglevel and postupgrade/postrestore OAuth-key checks retained. | ### Self hosting operations (12) diff --git a/apps/docs/content/docs/platform/enterprise/self-hosted.mdx b/apps/docs/content/docs/platform/enterprise/self-hosted.mdx index 27fdcdd4517..bd09e7efe64 100644 --- a/apps/docs/content/docs/platform/enterprise/self-hosted.mdx +++ b/apps/docs/content/docs/platform/enterprise/self-hosted.mdx @@ -30,6 +30,8 @@ DATA_DRAINS_ENABLED=false You can also leave the master switch unset and enable individual features. The [feature flag reference](#feature-flag-reference) lists them all. +The suite includes retention deletion. Review any retention windows your organizations have configured before turning it on, or set `DATA_RETENTION_ENABLED=false`. + ## Choose an organization model ### One organization for the instance diff --git a/apps/docs/content/docs/platform/self-hosting/architecture.mdx b/apps/docs/content/docs/platform/self-hosting/architecture.mdx index 5f4265ec939..d653d2b8c15 100644 --- a/apps/docs/content/docs/platform/self-hosting/architecture.mdx +++ b/apps/docs/content/docs/platform/self-hosting/architecture.mdx @@ -1,116 +1,52 @@ --- title: Architecture -description: Services, dependencies, request paths, and durable state in a self-hosted deployment +description: Services, request paths, and durable state in a self-hosted deployment --- -import { Callout } from '@/components/ui/callout' - -Sim runs an app, a realtime server, PostgreSQL, Redis, and a scheduler. This page shows their dependencies and the state you need to preserve. +Sim runs an app, a realtime server, PostgreSQL, Redis, and a scheduler. This page shows how they connect and what you must preserve. ## Services -| Service | Image | Port | State | Required | -|---|---|---|---|---| -| **app** | `ghcr.io/simstudioai/simstudio` | 3000 | Local uploads unless shared storage is configured | Yes | -| **realtime** | `ghcr.io/simstudioai/realtime` | 3002 | In-flight collaboration state | Yes | -| **migrations** | `ghcr.io/simstudioai/migrations` | — | One-shot schema and data migrations | Yes | -| **postgresql** | `pgvector/pgvector:pg17` | 5432 | Durable application data | Yes | -| **redis** | `redis:7-alpine` | 6379 | Rate limits, coordination, and live events | Yes (bundled by default) | -| **cron** | `ghcr.io/simstudioai/cron` (Compose) / `curlimages/curl` (Kubernetes) | — | None | Required for scheduled work | -| **pii** | `ghcr.io/simstudioai/pii` | 5001 | None | Optional | -| **ollama** | `ollama/ollama` | 11434 | Model cache | Optional | -| **telemetry** | `otel/opentelemetry-collector-contrib` | 4317/4318 | None | Optional | - -### App - -The Next.js app serves the workflow builder, API routes, and workflow orchestration. Local JavaScript runs in Node child workers using isolated-vm inside the app container. The app and those workers share the container's memory budget. The Helm chart requests 4 GiB and limits the app to 8 GiB; `docker-compose.prod.yml` sets an 8 GB memory limit without a reservation. - -E2B or Daytona moves supported code execution to a remote sandbox. `TRIGGER_DEV_ENABLED` routes asynchronous jobs to Trigger.dev; the default deployment uses database-backed jobs. See [Sandboxes](/platform/self-hosting/sandboxes) for the provider and image requirements. - -Any replica can serve files once shared object storage is configured. Before adding replicas, configure storage, Redis, and database connection capacity as described in [Scaling and high availability](/platform/self-hosting/scaling). - -### Realtime - -The Bun Socket.IO server carries collaborative editing, live execution updates, and collaborative documents. Clients connect at `/socket.io`. - -Realtime shares PostgreSQL and `BETTER_AUTH_SECRET` with the app, using Better Auth's shared-database-session pattern. It authenticates the same accounts without a separate login. - - - Realtime requires `REDIS_URL`, pointing at the same Redis as the app. The Socket.IO Redis adapter carries events between replicas, so members connected to different pods see each other's edits. - - -A realtime server must exist for editing and live updates. Set `realtime.enabled: false` in Helm only when `app.env.SOCKET_SERVER_URL` points to a realtime instance you run separately. - -### Migrations - -The migrator applies Drizzle SQL and registered data migrations, then exits. Compose runs it as a one-shot service. Helm runs it as an app init container, so migrations complete before that app pod starts. Later pods and rollouts run the migrator again; already-applied migrations are skipped. - -Migrations are forward-only. See [Upgrades](/platform/self-hosting/upgrades) for backup and rollback procedures. - -### PostgreSQL +| Service | Image | Port | Required | +| --- | --- | --- | --- | +| **app** | `ghcr.io/simstudioai/simstudio` | 3000 | Yes | +| **realtime** | `ghcr.io/simstudioai/realtime` | 3002 | Yes | +| **migrations** | `ghcr.io/simstudioai/migrations` | None | Yes, once per release | +| **postgresql** | `pgvector/pgvector:pg17` | 5432 | Yes | +| **redis** | `redis:7-alpine` | 6379 | Yes | +| **scheduler** | `ghcr.io/simstudioai/cron` (Compose), `curlimages/curl` CronJobs (Helm) | None | For scheduled work | +| **pii** | `ghcr.io/simstudioai/pii` | 5001 | Optional | +| **ollama** | `ollama/ollama` | 11434 | Optional | +| **copilot** | Private Mothership image | 8080 | Optional; see [Chat service](/platform/self-hosting/chat) | -Sim requires PostgreSQL with the pgvector extension for knowledge base embeddings. The bundled image uses PostgreSQL 17 and includes pgvector. On managed PostgreSQL, make the extension available; migrations issue `CREATE EXTENSION` where permissions allow. +**App.** The Next.js app serves the editor, the API, and workflow execution. Plain JavaScript runs in isolated-vm workers inside the app container and shares its memory; other code runs in a [remote sandbox](/platform/self-hosting/sandboxes). Background jobs run in the app on a database-backed queue. -PostgreSQL holds workflows, runs, logs, accounts, organizations, credentials, knowledge base chunks and embeddings, table data, and upload-session state. +**Realtime.** A Bun Socket.IO server for collaborative editing and live execution updates, served at `/socket.io`. It shares PostgreSQL, `BETTER_AUTH_SECRET`, and Redis with the app, so users sign in once. In Helm, `realtime.enabled: false` is only for pointing `SOCKET_SERVER_URL` at a realtime server you run elsewhere. -### Redis +**Migrations.** Apply schema and data migrations, then exit. Compose runs them before the app starts; Helm runs them as an init container on every app pod, and already-applied migrations are skipped. They are forward-only; see [Upgrades](/platform/self-hosting/upgrades). -Redis is required, even with one replica. It holds rate-limit buckets, one-time passcodes, and shared coordination state, and carries live events between processes. There is no PostgreSQL or process-local fallback, and the app refuses to start without `REDIS_URL`. See [Redis](/platform/self-hosting/redis) for everything it backs. - -### Scheduler - -Scheduled workflows, polling triggers, connector syncs, subscription renewal, and maintenance jobs call authenticated app endpoints. Helm provides CronJobs; Compose provides a supercronic service. See [Background jobs](/platform/self-hosting/background-jobs) for the shipped inventory and the additional upload-session cleanup schedule operators must configure. - -### Optional Chat service - -The chart can also render the optional `copilot` service, its separate PostgreSQL database, and its migration job. These are separate from the app and workflow database. Enabling them requires the service's image, license, credentials, and database configuration; see [Chat service](/platform/self-hosting/chat). - -## Where state lives - -| Store | Contents | Backup | -|---|---|---| -| **PostgreSQL** | Application data, including any separately enabled Chat-service database | `pg_dump`, managed snapshots, and point-in-time recovery | -| **Object storage** | Files, knowledge base documents, execution outputs, avatars, and logos | Bucket versioning and lifecycle policies | -| **Secrets** | `ENCRYPTION_KEY`, `API_ENCRYPTION_KEY`, `BETTER_AUTH_SECRET`, `INTERNAL_API_SECRET`, `CRON_SECRET` | Secret manager and separate recovery copies | - - - Without object storage, uploads are local: Compose keeps them in the `sim_uploads` volume on one host, and the Helm chart keeps them on each pod, lost when it is recreated. Configure [object storage](/platform/self-hosting/object-storage) before storing durable files or scaling. - - - - Back up `ENCRYPTION_KEY` separately from PostgreSQL. A database restore with a different key cannot decrypt workspace and personal environment variables, stored provider keys, MCP OAuth credentials, or deployment/chat secrets. Recovery requires the original key or re-encryption before rotation. - - -Redis is a cache and message bus, not the owner of committed application data. Losing it interrupts in-flight coordination and live updates; completed data remains in PostgreSQL and object storage. +**PostgreSQL** needs the pgvector extension. **Redis** is required at any replica count; see [Redis](/platform/self-hosting/redis). **The scheduler** calls authenticated app endpoints; see [Background jobs](/platform/self-hosting/background-jobs). ## Request paths | Traffic | Path | -|---|---| -| Editor / API | Browser → ingress or reverse proxy → app:3000 → PostgreSQL, Redis, storage | -| Collaboration | Browser → ingress → realtime:3002 (`/socket.io`, WebSocket upgrade) → Redis → other realtime pods | -| Cloud upload | Browser → app opens upload session → signed transfer instructions → browser uploads directly to storage → app verifies completion and records metadata | -| Local upload | Browser → app opens upload session → bytes stream through `/api/v2/uploads/...` to local disk | -| Workflow execution | Manual, API, webhook, or schedule trigger → app enqueues or orchestrates run → local code workers or remote sandbox → results/logs to PostgreSQL, progress markers to Redis | -| Background work | Scheduler → `Authorization: Bearer $CRON_SECRET` → internal app endpoint | +| --- | --- | +| Editor and API | Browser → proxy or ingress → app:3000 → PostgreSQL, Redis, object storage | +| Collaboration | Browser → proxy or ingress → realtime:3002 (`/socket.io`, WebSocket) → Redis → other realtime pods | +| File upload | Browser → app opens an upload session. With object storage, the browser uploads to the bucket with signed URLs; on local storage, bytes stream through the app. Downloads always go through the app. | +| Workflow execution | Trigger → app → local workers or remote sandbox → results in PostgreSQL, progress in Redis | +| Scheduled work | Scheduler → internal app:3000 with `Authorization: Bearer $CRON_SECRET` | +| Outbound | App → model providers, integrations, email, object storage, telemetry | -Cloud uploads use a single `PUT` through 50 MiB and multipart above that. Local uploads use a single `PUT` through 8 MiB and multipart above that. Cloud buckets need CORS for the Sim origin and must be reachable from browsers; downloads are proxied through the app. Local uploads need no bucket CORS configuration. +Expose only the app and realtime. PostgreSQL, Redis, PII, and the job endpoints stay internal. Cloud buckets must accept CORS requests from the Sim origin and be reachable from browsers. Uploads use multipart above 50 MiB on cloud storage and above 8 MiB on local storage. -## Network boundaries - -| From | To | Purpose | -|---|---|---| -| Internet | app:3000, realtime:3002 | Browser/API traffic | -| App, realtime | PostgreSQL:5432, Redis:6379 | Data and coordination | -| App | Object-storage endpoint | Storage operations and proxied downloads | -| Browser | Object-storage endpoint | Signed uploads | -| App | Model/integration APIs and email provider | Outbound calls | -| Scheduler | Internal app:3000 | Scheduled work | - -The proxy must support WebSocket upgrades, streams, and long-lived connections. The chart's optional NetworkPolicy excludes cloud metadata addresses from broad egress, but its default ingress peer is broad. Configure the actual peers and managed-datastore paths before enabling it. +## Where state lives -## Related docs +| Store | Holds | Back up with | +| --- | --- | --- | +| PostgreSQL | Workflows, runs, logs, accounts, credentials, knowledge base embeddings, tables | `pg_dump`, snapshots, point-in-time recovery | +| Object storage | Files, knowledge base documents, execution outputs, avatars | Bucket versioning, or volume backups for local storage | +| Secrets | `ENCRYPTION_KEY`, `API_ENCRYPTION_KEY`, `BETTER_AUTH_SECRET`, `INTERNAL_API_SECRET`, `CRON_SECRET` | A secret manager, plus a separate recovery copy | +| Redis | Rate limits, locks, one-time codes, live events | Nothing; losing it interrupts in-flight work only | -- [Reference architectures](/platform/self-hosting/reference-architectures) -- [Networking](/platform/self-hosting/networking) -- [Security and hardening](/platform/self-hosting/security) +A database backup is unreadable without its `ENCRYPTION_KEY`; see [Secrets](/platform/self-hosting/security#secrets). Local uploads are not shared across replicas; see [Object storage](/platform/self-hosting/object-storage). diff --git a/apps/docs/content/docs/platform/self-hosting/background-jobs.mdx b/apps/docs/content/docs/platform/self-hosting/background-jobs.mdx index 4d121822252..5b17756d2af 100644 --- a/apps/docs/content/docs/platform/self-hosting/background-jobs.mdx +++ b/apps/docs/content/docs/platform/self-hosting/background-jobs.mdx @@ -1,59 +1,27 @@ --- title: Background jobs -description: Scheduled workflows, polling triggers, and the cron endpoints that drive them +description: The scheduler that drives scheduled workflows, polling triggers, syncs, and cleanup --- import { Callout } from '@/components/ui/callout' -Scheduled workflows, polling triggers, connector syncs, and maintenance jobs depend on authenticated HTTP endpoints called by an external scheduler. - -Helm enables CronJobs by default; Docker Compose includes a `cron` service. Both use `CRON_SECRET` and the same shipped schedules. Upload-session cleanup needs an additional operator-configured job, described below. +Scheduled workflows, polling triggers, connector syncs, and maintenance run when a scheduler calls authenticated app endpoints. Helm deploys one CronJob per job and Compose runs a `cron` service; both run the [same jobs on the same schedules](#shipped-jobs). ## Authentication -Every endpoint is protected by `CRON_SECRET` and expects it as a bearer token: - -```bash -curl -f -s -S --max-time 60 \ - -H "Authorization: Bearer $CRON_SECRET" \ - https://sim.yourdomain.com/api/schedules/execute -``` - -Generate it like the other secrets: +Every endpoint expects `CRON_SECRET` as a bearer token, and the app and scheduler must hold the same value: ```bash -openssl rand -hex 32 +curl -fsS -H "Authorization: Bearer $CRON_SECRET" http://localhost:3000/api/schedules/execute ``` - - Background jobs require `CRON_SECRET`. Helm rejects a missing inline value when CronJobs are enabled. With a pre-created Secret or External Secrets, supply the key in that Secret; otherwise cron pods cannot start. Endpoints reject calls without the matching secret. - - -Point cron at an **internal** address where possible (the in-cluster Service, or `localhost` on a single node). These endpoints should not be reachable from the internet; if they are, `CRON_SECRET` is the only thing protecting them. +Generate it with `openssl rand -hex 32`. The shipped schedulers call the app's internal address; keep these endpoints off the public internet, where `CRON_SECRET` would be their only protection. ## Kubernetes -CronJobs are enabled by default. Supply `CRON_SECRET` through the app Secret and ensure cron pods can reach the internal app Service. - -```yaml -cronjobs: - enabled: true -``` - -Each `curlimages/curl` pod calls the internal app Service, which routes the request to one replica. `concurrencyPolicy: Forbid` prevents overlapping Jobs for that CronJob; the app also handles overlap for detached work. - -| Setting | Shipped behavior | -|---|---| -| Completed/failed Job history | Three successful and one failed Job | -| Finished-Job TTL | 600 seconds; collect logs before deletion | -| Job deadline | 300 seconds by default; outbox uses 900, idempotency cleanup 360 | -| Kubernetes retry limit | No chart `backoffLimit` key; Kubernetes defaults to six retries after the initial failure | -| Request retries | Three shell attempts, ten seconds apart; each uses `curl --retry 2 --retry-delay 5` | -| Request timeout | 60 seconds by default, with per-job overrides; outbox uses 810 seconds | +CronJobs are on by default (`cronjobs.enabled`); with inline secrets, the chart refuses to render without `CRON_SECRET`. Each Job runs `curl` against the app Service with three attempts, each with curl retries, a 60-second request timeout (longer for a few slow jobs), and a 300-second Job deadline. Kubernetes keeps three successful and one failed Job for 600 seconds; collect logs before they go. -The Job deadline includes attempts and controller backoff. It can end a Job before the retry limit is reached and also stops a hung request. - -Disable individual jobs you do not need — billing reconciliation is the obvious one on a self-hosted install: +Turn off a job you do not need, such as billing reconciliation without billing: ```yaml cronjobs: @@ -62,9 +30,7 @@ cronjobs: enabled: false ``` -Do not disable schedule execution, outbox processing, or subscription renewal unless you know you do not use the features behind them. - -Check they are running: +Keep schedule execution, outbox processing, and subscription renewal on unless you use none of their features. ```bash kubectl get cronjobs -n simstudio @@ -72,60 +38,38 @@ kubectl get jobs -n simstudio --sort-by=.metadata.creationTimestamp | tail kubectl logs -n simstudio 'job/' ``` -Inspect stale schedules and failed Jobs. A stale `LAST SCHEDULE` points to controller, suspension, or deadline settings; a 401 in Job logs points to authentication. `Forbid` can skip a tick while an earlier Job remains active. Alert on successful completion as described in [Observability](/platform/self-hosting/observability). +A stale `LAST SCHEDULE` points to suspension, controller, or deadline settings; `concurrencyPolicy: Forbid` skips a tick while the previous Job runs. ## Docker Compose -Generate a secret, then save it as `CRON_SECRET` in the `.env` file next to your Compose file. Replace an existing value rather than adding a duplicate. The app and scheduler must receive the same value. - -```bash -openssl rand -hex 32 -``` - -Recreate the services after updating `.env`: - -```bash -docker compose -f docker-compose.prod.yml up -d -``` - -Without it the `cron` service logs exactly what to set — including a freshly generated value — and exits, leaving the rest of the stack running. Schedules live in `docker/crontab` and mirror `helm/sim/values.yaml` `cronjobs.jobs` one-for-one. - -An older install may lack `CRON_SECRET`; add it to `.env` and run `up -d` to enable the scheduler. - -The service runs [supercronic](https://github.com/aptible/supercronic) rather than the app image: it logs each job's output to the container log, forwards `SIGTERM` so `docker compose stop` is graceful, and will not start an iteration while the previous one is still running. +The `cron` service runs [supercronic](https://github.com/aptible/supercronic) with the schedules in `docker/crontab`. Without `CRON_SECRET` in `.env` it prints what to set and exits; add the value and run `docker compose -f docker-compose.prod.yml up -d`. ```bash docker compose -f docker-compose.prod.yml logs -f cron ``` -A healthy log line looks like: - -``` -level=info msg=starting iteration=0 job.schedule="*/1 * * * *" -level=info msg="job succeeded" iteration=0 -``` - -The published cron image contains its crontab. Editing the repository copy and restarting that image does not change its jobs. To customize them, copy `docker/crontab` to an operator-owned file, edit it, and mount it with a Compose override: +Healthy output shows `msg="job succeeded"` for each run. The crontab is baked into the cron image; to change it, copy `docker/crontab` from your release, edit it, and mount it with an overlay: ```yaml -# cron-custom.yml +# cron-custom.yml — docker compose -f docker-compose.prod.yml -f cron-custom.yml up -d cron services: cron: volumes: - ./sim-crontab:/etc/sim/crontab:ro ``` -```bash -docker compose -f docker-compose.prod.yml -f cron-custom.yml up -d cron -``` - -Alternatively, build a custom image from `docker/cron.Dockerfile` with your crontab and configure Compose to use it. +## Jobs you schedule yourself [#schedule-upload-session-cleanup] -## Schedule upload-session cleanup +The shipped schedules leave these out. Add them as operator-owned jobs with the same `CRON_SECRET`: -The cleanup endpoint exists, but neither shipped scheduler calls it. Configure your own authenticated schedule for `/api/cron/cleanup-tasks` to expire upload sessions and reclaim abandoned upload state. It also dispatches task-retention cleanup according to configured policy. +| Endpoint | When | Does | +| --- | --- | --- | +| `/api/cron/cleanup-tasks` | Every deployment, hourly | Expires abandoned upload sessions and their partial uploads. With retention on, it also applies Chat-task retention | +| `/api/logs/cleanup` | With `DATA_RETENTION_ENABLED`, daily | Log retention | +| `/api/cron/cleanup-soft-deletes` | With `DATA_RETENTION_ENABLED`, daily | Purges soft-deleted resources past retention | +| `/api/cron/cleanup-file-versions` | With `DATA_RETENTION_ENABLED`, daily | Deletes previous file versions past retention | -For Helm, add an operator-owned job to your values file. This example runs hourly; choose a cadence and timeout for your workload: +On Helm, add each to your values: ```yaml cronjobs: @@ -137,81 +81,62 @@ cronjobs: path: /api/cron/cleanup-tasks requestTimeoutSeconds: 300 activeDeadlineSeconds: 360 - concurrencyPolicy: Forbid ``` -For Compose, add this line to the mounted or custom-image crontab described above: +On Compose, add a line per endpoint to your mounted crontab: ```text 0 * * * * curl -fsS -m 300 -o /dev/null -H "Authorization: Bearer $CRON_SECRET" "$SIM_URL/api/cron/cleanup-tasks" ``` -Use the internal app address and the same `CRON_SECRET`. Check job logs for a successful response. Provider lifecycle rules remain a second layer for incomplete multipart state; see [Object storage](/platform/self-hosting/object-storage#configure-incomplete-multipart-cleanup). - -## Verifying - -Create a workflow with a Schedule trigger set to every minute, deploy it, and watch the Logs view. An execution should appear within ~2 minutes. If nothing appears: - -1. Check the scheduler's own logs — `docker compose -f docker-compose.prod.yml logs cron`, or `kubectl get cronjobs -n simstudio` for a recent `LAST SCHEDULE`. -2. Confirm the app and the scheduler share the same `CRON_SECRET`. A mismatch shows up as `401` in the scheduler log. -3. A `202` means the endpoint accepted the run; it does not confirm a schedule was due, so check the Logs view. - -## Shipped job reference - -| Job | Endpoint | Schedule | Drives | -|---|---|---|---| -| Schedule execution | `/api/schedules/execute` | `*/1 * * * *` | **Scheduled workflows** | -| Gmail poll | `/api/webhooks/poll/gmail` | `*/1 * * * *` | Gmail trigger | -| Outlook poll | `/api/webhooks/poll/outlook` | `*/1 * * * *` | Outlook trigger | -| IMAP poll | `/api/webhooks/poll/imap` | `*/1 * * * *` | IMAP trigger | -| RSS poll | `/api/webhooks/poll/rss` | `*/1 * * * *` | RSS trigger | -| Google Sheets poll | `/api/webhooks/poll/google-sheets` | `*/1 * * * *` | Sheets trigger | -| Google Drive poll | `/api/webhooks/poll/google-drive` | `*/1 * * * *` | Drive trigger | -| Google Calendar poll | `/api/webhooks/poll/google-calendar` | `*/1 * * * *` | Calendar trigger | -| HubSpot poll | `/api/webhooks/poll/hubspot` | `*/1 * * * *` | HubSpot trigger | -| Time pause/resume | `/api/resume/poll` | `*/1 * * * *` | Workflows paused on a timer | -| Outbox processing | `/api/webhooks/outbox/process` | `*/1 * * * *` | Transactional-outbox retries for billing, membership, enterprise issuance, and workflow-deployment side effects | -| Workspace file search dispatch | `/api/cron/workspace-file-search-dispatch` | `*/1 * * * *` | Dispatches indexing work for workspace file search | -| Knowledge projection | `/api/cron/knowledge-projection` | `*/1 * * * *` | Brings knowledge base search up to date with document, permission, and chunk changes | -| Activity rollup | `/api/cron/activity-rollup` | `*/2 * * * *` | Maintains the hourly workflow activity rollup that serves organization activity; idle unless `ACTIVITY_ROLLUP_MAINTENANCE` is set | -| Table row-change fold | `/api/cron/fold-table-row-changes` | `*/1 * * * *` | Folds the table row-change log into each table's stored row count and version | -| Connector sync | `/api/knowledge/connectors/sync` | `*/5 * * * *` | Knowledge base connector syncs | -| Connector member sync | `/api/knowledge/connectors/member-sync` | `*/5 * * * *` | Per-member content/access sync for indexed connectors; live Search sources are skipped | -| Connector directory sync | `/api/knowledge/connectors/directory-sync` | `*/5 * * * *` | Refreshes stored groups for indexed administrator-mode connectors; live Search sources are skipped | -| Workspace events poll | `/api/workspace-events/poll` | `*/15 * * * *` | Workspace event triggers | -| Table row TTL cleanup | `/api/cron/cleanup-table-row-ttl` | `*/15 * * * *` | Deletes table rows whose TTL column has expired | -| Stale execution cleanup | `/api/cron/cleanup-stale-executions` | `*/30 * * * *` | Fails runs whose worker died without finishing — workflow executions, background jobs, table jobs and table runs — so they stop showing as running | -| OAuth token cleanup | `/api/cron/cleanup-oauth-tokens` | `0 * * * *` | Deletes access and refresh tokens after the retention tail | -| Credential Group link cleanup | `/api/cron/cleanup-credential-group-links` | `20 * * * *` | Deletes workflow connection-request log rows after two days and connect or self-enrollment links a day after they expire | -| Activity history cleanup | `/api/cron/cleanup-activity-history` | `45 4 * * *` | Deletes organization adoption history past its retention: daily member activity, daily Search integration counts and Search MCP call metadata after 400 days | -| Workspace source staging cleanup | `/api/cron/cleanup-source-staging` | `30 * * * *` | Deletes binary files staged for a workspace source apply a day after they were last staged | -| SCIM reconciliation | `/api/cron/scim-reconcile` | `17 * * * *` | Re-applies directory group mappings | -| Data drains | `/api/cron/run-data-drains` | `*/15 * * * *` | Enterprise data drains; each drain runs only when its own cadence is due | -| Renew subscriptions | `/api/cron/renew-subscriptions` | `0 */12 * * *` | Renews Microsoft Teams chat subscriptions (Graph caps them at ~3 days) | -| Billing cycle close | `/api/cron/billing-cycle-close` | `0 */6 * * *` | Billing only — final overage collection and per-period tracker reset | -| Reconcile billing seats | `/api/cron/reconcile-billing-seats` | `0 * * * *` | Billing only — safe to disable when self-hosted | -| Reconcile inbox entitlement | `/api/cron/reconcile-inbox-entitlement` | `0 3 * * *` | Inbox access reconciliation | -| Cleanup sandbox images | `/api/cron/cleanup-sandbox-images` | `30 4 * * *` | Reclaims sandbox images | -| Cleanup session sandboxes | `/api/cron/cleanup-session-sandboxes` | `*/5 * * * *` | Kills chat workbenches paused past their retention window | -| Idempotency key cleanup | `/api/webhooks/cleanup/idempotency` | `0 5 * * *` | Deletes deduplication records older than seven days | - -Subscription renewal covers Microsoft Teams chat triggers. Their Graph subscriptions last at most three days; rich notifications have a shorter limit. Gmail, Outlook, Drive, Calendar, and Sheets use the per-minute polling jobs instead. See [Microsoft Graph subscription lifetimes](https://learn.microsoft.com/en-us/graph/change-notifications-overview). SCIM reconciliation calls its authenticated endpoint directly each hour; it does not require Trigger.dev. - -## Concurrency - -On the default database-backed queue, scheduled execution capacity is shared across the deployment: - -| Variable | Default | Applies to | -|---|---|---| -| `SCHEDULE_EXECUTION_CONCURRENCY_LIMIT` | `30` | Scheduled workflows in flight across the database-backed queue; also the schedule task limit on Trigger.dev | - - - `WORKFLOW_EXECUTION_CONCURRENCY_LIMIT`, `WEBHOOK_EXECUTION_CONCURRENCY_LIMIT`, and `RESUME_EXECUTION_CONCURRENCY_LIMIT` are `concurrencyLimit` settings on Trigger.dev task definitions. They have **no effect** unless `TRIGGER_DEV_ENABLED` is set, and neither the Helm chart nor Docker Compose configures Trigger.dev — so on a default self-host they are inert. - - -Adding replicas does not multiply the database queue's schedule cap. Raise it only after measuring memory and database headroom. The app orchestrates runs; local JavaScript uses Node child workers inside its container. - -## Related docs - -- [Observability](/platform/self-hosting/observability) -- [Upgrades](/platform/self-hosting/upgrades) +Retention windows themselves are set per organization; see [Data retention](/platform/enterprise/data-retention). + +## Verify + +Deploy a workflow with an every-minute Schedule trigger and watch its logs. A run should appear within two minutes. If not, read the scheduler logs: `401` means `CRON_SECRET` differs, and `202` means the endpoint accepted the call, not that a schedule was due. + +## Shipped jobs + +Generated from `cronjobs.jobs` in the chart's `values.yaml`, which `docker/crontab` mirrors. + +{/* self-hosting-cron-jobs:begin — generated by `bun run generate:self-hosting-docs`; do not edit between markers */} + +| Job | Endpoint | Schedule | Does | +| --- | --- | --- | --- | +| `schedule-execution` | `/api/schedules/execute` | `*/1 * * * *` | Runs scheduled workflows | +| `gmail-webhook-poll` | `/api/webhooks/poll/gmail` | `*/1 * * * *` | Polls Gmail for the Gmail trigger | +| `outlook-webhook-poll` | `/api/webhooks/poll/outlook` | `*/1 * * * *` | Polls Outlook for the Outlook trigger | +| `rss-webhook-poll` | `/api/webhooks/poll/rss` | `*/1 * * * *` | Polls feeds for the RSS trigger | +| `imap-webhook-poll` | `/api/webhooks/poll/imap` | `*/1 * * * *` | Polls mailboxes for the IMAP trigger | +| `google-sheets-webhook-poll` | `/api/webhooks/poll/google-sheets` | `*/1 * * * *` | Polls Google Sheets for the Sheets trigger | +| `google-drive-webhook-poll` | `/api/webhooks/poll/google-drive` | `*/1 * * * *` | Polls Google Drive for the Drive trigger | +| `google-calendar-webhook-poll` | `/api/webhooks/poll/google-calendar` | `*/1 * * * *` | Polls Google Calendar for the Calendar trigger | +| `hubspot-webhook-poll` | `/api/webhooks/poll/hubspot` | `*/1 * * * *` | Polls HubSpot for the HubSpot trigger | +| `renew-subscriptions` | `/api/cron/renew-subscriptions` | `0 */12 * * *` | Renews Microsoft Teams chat subscriptions, which Microsoft Graph expires after about three days | +| `billing-cycle-close` | `/api/cron/billing-cycle-close` | `0 */6 * * *` | Billing only: collects final overage and resets per-period usage trackers | +| `reconcile-billing-seats` | `/api/cron/reconcile-billing-seats` | `0 * * * *` | Billing only: reconciles subscription seats; safe to disable without billing | +| `reconcile-inbox-entitlement` | `/api/cron/reconcile-inbox-entitlement` | `0 3 * * *` | Releases Sim Mailer inboxes for workspaces whose plan lapsed | +| `workspace-events-poll` | `/api/workspace-events/poll` | `*/15 * * * *` | Fires workspace event triggers | +| `time-pause-resume-poll` | `/api/resume/poll` | `*/1 * * * *` | Resumes workflows paused on a timer | +| `connector-sync` | `/api/knowledge/connectors/sync` | `*/5 * * * *` | Syncs knowledge base connectors | +| `connector-member-sync` | `/api/knowledge/connectors/member-sync` | `*/5 * * * *` | Syncs per-member content and access for indexed connectors | +| `connector-directory-sync` | `/api/knowledge/connectors/directory-sync` | `*/5 * * * *` | Refreshes stored groups for indexed administrator-mode connectors | +| `run-data-drains` | `/api/cron/run-data-drains` | `*/15 * * * *` | Runs the enterprise data drains that are due | +| `people-directory-sync` | `/api/cron/people-directory-sync` | `*/5 * * * *` | Refreshes connected People directories and delivers pending SCIM changes | +| `scim-reconcile` | `/api/cron/scim-reconcile` | `17 * * * *` | Re-applies SCIM directory group mappings | +| `cleanup-table-row-ttl` | `/api/cron/cleanup-table-row-ttl` | `*/15 * * * *` | Deletes table rows whose TTL column has expired | +| `cleanup-oauth-tokens` | `/api/cron/cleanup-oauth-tokens` | `0 * * * *` | Deletes OAuth access and refresh tokens after their retention tail | +| `cleanup-credential-group-links` | `/api/cron/cleanup-credential-group-links` | `20 * * * *` | Deletes Credential Group connection-request logs and expired connect links | +| `cleanup-activity-history` | `/api/cron/cleanup-activity-history` | `45 4 * * *` | Deletes organization activity history past its 400-day retention | +| `cleanup-source-staging` | `/api/cron/cleanup-source-staging` | `30 * * * *` | Deletes files staged for a workspace source apply a day after last use | +| `cleanup-sandbox-images` | `/api/cron/cleanup-sandbox-images` | `30 4 * * *` | Deletes unused prebuilt sandbox images past their retention window | +| `cleanup-session-sandboxes` | `/api/cron/cleanup-session-sandboxes` | `*/5 * * * *` | Stops idle chat workbenches and removes finished Kubernetes sandbox pods | +| `outbox-process` | `/api/webhooks/outbox/process` | `*/1 * * * *` | Retries transactional-outbox side effects for billing, membership, and deployments | +| `workspace-file-search-dispatch` | `/api/cron/workspace-file-search-dispatch` | `*/1 * * * *` | Dispatches indexing work for workspace file search | +| `knowledge-projection` | `/api/cron/knowledge-projection` | `*/1 * * * *` | Brings knowledge base search up to date with document, permission, and chunk changes | +| `activity-rollup` | `/api/cron/activity-rollup` | `*/2 * * * *` | Maintains the hourly workflow activity rollup; idle unless ACTIVITY_ROLLUP_MAINTENANCE is on | +| `fold-table-row-changes` | `/api/cron/fold-table-row-changes` | `*/1 * * * *` | Folds the table row-change log into each table's row count and version | +| `cleanup-stale-executions` | `/api/cron/cleanup-stale-executions` | `*/30 * * * *` | Fails runs whose worker died without finishing, and prunes old run bookkeeping | +| `idempotency-cleanup` | `/api/webhooks/cleanup/idempotency` | `0 5 * * *` | Deletes deduplication records older than seven days | + +{/* self-hosting-cron-jobs:end */} diff --git a/apps/docs/content/docs/platform/self-hosting/chat.mdx b/apps/docs/content/docs/platform/self-hosting/chat.mdx index 0337cfd8e6f..2f205c44e23 100644 --- a/apps/docs/content/docs/platform/self-hosting/chat.mdx +++ b/apps/docs/content/docs/platform/self-hosting/chat.mdx @@ -6,7 +6,7 @@ description: Connect self-hosted Sim to the Sim-hosted Chat service, or run the import { Tab, Tabs } from '@/components/ui/tabs' import { Callout } from '@/components/ui/callout' -Chat, the Sim Chat workflow block, and Inbox run on a separate service, the Mothership. A self-hosted Sim either connects to the Mothership Sim hosts or to one you run beside it. Without either, set `NEXT_PUBLIC_CHAT_DISABLED=true` to hide Chat. +Chat, the Sim Chat workflow block, and Inbox run on a separate service, the Mothership. A self-hosted Sim connects either to the Mothership Sim hosts or to one you run beside it. | | Sim-hosted Mothership | Your own Mothership | | --- | --- | --- | @@ -25,7 +25,17 @@ These are set on **Sim**, not on the Mothership. | `MOTHERSHIP_SIM_TRANSPORT` | How the Mothership reaches Sim. `direct`: it calls Sim at its own `SIM_ENDPOINT`. `checkpoint`: Sim collects workspace tool calls by polling the Mothership over outbound HTTPS, so the Sim-hosted service needs no route into Sim. A Mothership you run still reaches `SIM_ENDPOINT` for account validation and usage reporting with either transport. Self-hosted Sim defaults to `checkpoint` | | `INTERNAL_API_SECRET` | Sim's existing secret. Your own Mothership uses the same value | -For the Sim-hosted service, set `COPILOT_API_KEY` and keep the defaults. Chat attachments also need an object storage bucket; see [Object storage](/platform/self-hosting/object-storage). +## Use the Sim-hosted service + +1. Sign in to [sim.ai](https://www.sim.ai) with any account and create a key at [sim.ai/selfhost/settings/chat-keys](https://www.sim.ai/selfhost/settings/chat-keys). The page exists only on Sim Cloud, not on your deployment. +2. Set `COPILOT_API_KEY` to it, keep the other defaults, and recreate the app. On Compose, `npx sim-setup add chat` writes it for you. +3. Remove `NEXT_PUBLIC_CHAT_DISABLED`, or set it to `false`. + +Chat attachments also need the Chat attachments bucket; see [Object storage](/platform/self-hosting/object-storage). + +## Hide Chat + +Without a Mothership, set `NEXT_PUBLIC_CHAT_DISABLED=true` on the app. Workspaces then open on their first workflow, with no chats list or editor Chat panel. `npx sim-setup` sets it when you skip the Chat key. ## Run the Mothership diff --git a/apps/docs/content/docs/platform/self-hosting/docker.mdx b/apps/docs/content/docs/platform/self-hosting/docker.mdx index f8963d17e4c..dfaf1a26465 100644 --- a/apps/docs/content/docs/platform/self-hosting/docker.mdx +++ b/apps/docs/content/docs/platform/self-hosting/docker.mdx @@ -1,290 +1,169 @@ --- title: Docker -description: Deploy Sim with Docker Compose and verify its services +description: Run Sim on one host with Docker Compose --- import { Callout } from '@/components/ui/callout' -Use the production Compose stack for a single-node installation. It starts the app, realtime, PostgreSQL with pgvector, Redis, migrations, and the scheduler. +The production Compose stack runs the app, realtime, PostgreSQL with pgvector, Redis, migrations, and the scheduler on one host. ## Prerequisites -- Docker Engine or Docker Desktop, running. -- Docker Compose 2.24.0 or later. The file uses optional `env_file` entries introduced in that version. -- Node.js 20 or later, which provides `npx` for the `sim-setup` CLI. -- Available host ports 3000 and 3002, with enough resources for your workload. See [resource examples](/platform/self-hosting#requirements). -- A public domain and TLS proxy for remote access. +- Docker Engine or Docker Desktop with Compose 2.24.0 or later. +- Node.js 20 or later, for `npx sim-setup`. +- Free host ports 3000 and 3002, and the [resources](/platform/self-hosting#requirements) for your workload. +- A domain and a TLS proxy for access from other machines. ## Quick start ```bash -npx sim-setup +npx sim-setup --url https://sim.yourdomain.com ``` -The wizard creates `./sim` with a generated `.env` and production Compose file, then starts published container images. Pass `--dir ` for another directory, and `--url https://sim.yourdomain.com` to set the public URL (Custom setup also asks for it). Open [http://localhost:3000](http://localhost:3000), or your public URL. `bunx sim-setup` works too if you use Bun. +The wizard writes `docker-compose.prod.yml` and a generated `.env` to `./sim`, and starts the published images. Leave out `--url` to serve [http://localhost:3000](http://localhost:3000) only. `--dir ` picks another directory, and `bunx sim-setup` works too. -For a manual installation, obtain the Compose file from a source checkout: +## Manual install [#production-setup] + +Fetch the Compose file from the [release](https://github.com/simstudioai/sim/releases) you want to run: ```bash -git clone https://github.com/simstudioai/sim.git -cd sim +mkdir sim && cd sim +SIM_VERSION= +curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/${SIM_VERSION}/docker-compose.prod.yml" ``` -Then follow the configuration steps below. - -## Production setup - -### 1. Configure the environment - -For a new installation, create `.env` next to `docker-compose.prod.yml`: +Create `.env` beside it. Run this once, for a new installation only: it generates new secrets, and an existing database cannot be read with them. ```bash umask 077 cat > .env << EOF +SIM_VERSION=${SIM_VERSION} +NEXT_PUBLIC_APP_URL=https://sim.yourdomain.com BETTER_AUTH_SECRET=$(openssl rand -hex 32) ENCRYPTION_KEY=$(openssl rand -hex 32) -INTERNAL_API_SECRET=$(openssl rand -hex 32) API_ENCRYPTION_KEY=$(openssl rand -hex 32) +INTERNAL_API_SECRET=$(openssl rand -hex 32) CRON_SECRET=$(openssl rand -hex 32) -NEXT_PUBLIC_APP_URL=https://sim.yourdomain.com -POSTGRES_USER=postgres POSTGRES_PASSWORD=$(openssl rand -hex 24) -POSTGRES_DB=simstudio +LOG_LEVEL=INFO +# Chat: set COPILOT_API_KEY, or keep Chat hidden +NEXT_PUBLIC_CHAT_DISABLED=true EOF ``` -If you already ran the wizard or have an existing installation, edit that `.env` and retain its keys and database credentials. Do not rerun this creation command over it. - -Compose derives `BETTER_AUTH_URL` from `NEXT_PUBLIC_APP_URL` and `DATABASE_URL` from `POSTGRES_*`. Setting either derived variable in `.env` does not override the service definition. To use an external database, maintain a Compose configuration that supplies the same external DSN to the app, realtime, and migrations and adjusts their bundled-database dependencies. - -Keep `POSTGRES_USER`, `POSTGRES_PASSWORD`, and `POSTGRES_DB` URL-safe: letters, digits, `.`, `_`, `~`, or `-`. Compose inserts them into the DSN without escaping; values containing `@`, `/`, `?`, `#`, `%`, or spaces can initialize PostgreSQL but prevent app connections. Hex output from `openssl` is safe. - - - Back up `ENCRYPTION_KEY` and `API_ENCRYPTION_KEY` separately from the server. Restoring the database with different keys leaves encrypted values unreadable. `ENCRYPTION_KEY` protects environment variables, provider keys, MCP OAuth credentials, and deployment/Chat secrets. `API_ENCRYPTION_KEY` protects stored Sim API-key material; when absent, legacy API keys can be stored in plain text. - - -Compose refuses startup without `BETTER_AUTH_SECRET`, `ENCRYPTION_KEY`, `INTERNAL_API_SECRET`, or `POSTGRES_PASSWORD`. PostgreSQL applies its credentials only when initializing a new volume; changing `.env` does not change an existing database password. See [Postgres on Compose](/platform/self-hosting/security#postgres-on-compose) before rotating it. - -Set `CRON_SECRET` for scheduled work. Without it, the cron service prints instructions and exits; the other services can still run. Images use `latest` unless you set `SIM_VERSION`; the separate scheduler image uses `SIM_CRON_VERSION`. Pin and upgrade deliberately using [Upgrades](/platform/self-hosting/upgrades). - -### 2. Configure durable uploads - -Without object storage, the app stores uploads in the `sim_uploads` volume, so they survive container recreation and updates. It stays on this host and needs its own backup. A one-shot `uploads-init` service makes it writable by the app user. - -Follow [Object storage](/platform/self-hosting/object-storage) for AWS S3, Azure Blob, or Google Cloud Storage. - -#### Existing installs: keep uploads from before the volume - -If your install predates the `sim_uploads` volume, uploads live inside the app container and recreating it discards them. Copy them out before switching to the new Compose file or running `npx sim-setup update`, then copy them in: - -```bash -docker compose -f docker-compose.prod.yml cp simstudio:/app/apps/sim/uploads ./uploads-backup -# switch to the new docker-compose.prod.yml (or run npx sim-setup update), then: -docker compose -f docker-compose.prod.yml cp ./uploads-backup/. simstudio:/app/apps/sim/uploads -docker compose -f docker-compose.prod.yml exec -u 0 simstudio chown -R nextjs:nodejs /app/apps/sim/uploads -``` +- Compose derives `BETTER_AUTH_URL` from `NEXT_PUBLIC_APP_URL` and `DATABASE_URL` from `POSTGRES_USER`, `POSTGRES_PASSWORD`, and `POSTGRES_DB`; setting either derived variable in `.env` has no effect. +- Compose refuses to start without `BETTER_AUTH_SECRET`, `ENCRYPTION_KEY`, `INTERNAL_API_SECRET`, or `POSTGRES_PASSWORD`. Keep the `POSTGRES_*` values URL-safe (letters, digits, `.`, `_`, `~`, `-`), because they are inserted into the database URL unescaped. +- PostgreSQL applies its credentials only when it creates the volume; changing `.env` later does not change the password. See [Postgres on Compose](/platform/self-hosting/security#postgres-on-compose). +- Without `CRON_SECRET` the scheduler prints what to set and exits; everything else runs. See [Background jobs](/platform/self-hosting/background-jobs). +- Back up `.env` now. The encryption keys cannot be recovered; see [Secrets](/platform/self-hosting/security#secrets). +- [Chat](/platform/self-hosting/chat) needs `COPILOT_API_KEY`; set it and remove `NEXT_PUBLIC_CHAT_DISABLED` to show Chat. -### 3. Start and verify services +## Start and check ```bash docker compose -f docker-compose.prod.yml up -d docker compose -f docker-compose.prod.yml ps -a -docker compose -f docker-compose.prod.yml logs migrations curl -fsS http://localhost:3000/api/health ``` | Service | Host port | Purpose | | --- | --- | --- | -| `simstudio` | 3000 | App; 8G memory limit. | -| `realtime` | 3002 | WebSocket service; 1G memory limit. | -| `db` | Not published | PostgreSQL 17 with pgvector. | -| `redis` | Not published | Required. Rate limits, shared coordination, pub/sub, and caches. | -| `cron` | None | Calls background job endpoints. | -| `migrations` | None | Applies migrations once, then exits. | -| `uploads-init` | None | Hands the uploads volume to the app user once, then exits. | - -Expect five services running, and `migrations` and `uploads-init` exited successfully. The migrator has no healthcheck because it is a one-shot job. - -```bash -docker compose -f docker-compose.prod.yml logs -f cron -``` - -Confirm the scheduler calls succeed, then run [Verify your install](/platform/self-hosting/verify). - -### 4. Serve the public origin over TLS - -A host-installed Caddy proxy can obtain and renew certificates for your domain. For example: - -```text -sim.yourdomain.com { - request_body { - max_size 250MB - } - - handle /socket.io/* { - reverse_proxy localhost:3002 - } - - reverse_proxy localhost:3000 { - flush_interval -1 - } -} -``` - -Route `/socket.io` to realtime on 3002 and other requests to the app on 3000. The 250 MB decimal Caddy limit clears the configured 220 MiB deployed-chat cap, but the app's current Next.js proxy buffer still limits matching requests to 10 MiB. See [Request size limits](/platform/self-hosting/networking#request-size-limits) before increasing payload sizes. `flush_interval -1` explicitly disables response buffering; Caddy already flushes SSE immediately. It also keeps the upstream request running if the client disconnects. See [Caddy streaming behavior](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#streaming). - -When the proxy runs on the same host, set `SIM_APP_PUBLISH=127.0.0.1:3000` and `SIM_REALTIME_PUBLISH=127.0.0.1:3002` in `.env` so the app and realtime are reachable only through it. Keep the ports; `sim-setup` checks 3000 and 3002. - -This example assumes Caddy runs on the Docker host. A containerized proxy needs reachable Compose service addresses instead of its own `localhost`. For Nginx, Traefik, cloud load balancers, or separate socket hosts, see [Networking](/platform/self-hosting/networking). - -## Ollama - -### External Ollama - -For production, keep this Compose stack and point `OLLAMA_URL` at an Ollama server. If it runs on the Docker host, save the address in `.env` so later recreations retain it: - -```bash -OLLAMA_URL=http://host.docker.internal:11434 -``` - -Production Compose maps `host.docker.internal` to the host gateway, including on Linux. You can instead use a reachable host IP. The Ollama server must listen on an interface reachable from the container. On Linux, bind it to the Docker bridge address that `host.docker.internal` resolves to, usually `OLLAMA_HOST=172.17.0.1:11434` (check with `ip -4 addr show docker0`). Ollama's API has no authentication, so listen on `0.0.0.0` only behind a firewall that blocks port 11434 from outside the host. +| `simstudio` | 3000 | App; 8 GB memory limit | +| `realtime` | 3002 | WebSocket server; 1 GB memory limit | +| `db` | None | PostgreSQL 17 with pgvector | +| `redis` | None | Required: rate limits, coordination, and live events | +| `cron` | None | Calls the background job endpoints | +| `migrations` | None | Applies migrations, then exits | +| `uploads-init` | None | Makes the uploads volume writable, then exits | -```bash -docker compose -f docker-compose.prod.yml up -d -``` +Then run [Verify your install](/platform/self-hosting/verify). - - Container `localhost` is the container itself. The default `http://localhost:11434` does not reach an Ollama server on the host. - +Without object storage, uploads go to the `sim_uploads` volume on this host. Back it up, or configure [object storage](/platform/self-hosting/object-storage). -### Bundled Ollama +## Serve your domain over TLS -`docker-compose.ollama.yml` is an overlay on `docker-compose.prod.yml`: it adds an Ollama server to the production stack and points the app at it, so the stack keeps the published images, the required secrets, Redis, and cron. Ollama is reachable only inside the Compose network, as `ollama:11434`. +Put a TLS proxy in front of the stack. Route `/socket.io` to realtime on port 3002 and everything else to the app on port 3000, with WebSocket upgrades and response streaming enabled. [Networking](/platform/self-hosting/networking#reverse-proxy-configuration) has Caddy, Nginx, and Traefik configurations. -Add the address to `.env` first. The overlay refuses to start without it, and keeping it in `.env` means a later run of `docker-compose.prod.yml` alone still reaches Ollama: +When the proxy runs on the same host, publish the app and realtime on loopback only. Keep the ports, which `sim-setup` checks: ```bash -OLLAMA_URL=http://ollama:11434 +SIM_APP_PUBLISH=127.0.0.1:3000 +SIM_REALTIME_PUBLISH=127.0.0.1:3002 ``` -Start the stack with exactly one server profile: +## External PostgreSQL and Redis -```bash -# NVIDIA GPU (requires the NVIDIA Container Toolkit) -docker compose -f docker-compose.prod.yml -f docker-compose.ollama.yml --profile gpu up -d +To use your own Redis, set `REDIS_URL` in `.env` and recreate the stack; the app and realtime both read it. -# CPU only -docker compose -f docker-compose.prod.yml -f docker-compose.ollama.yml --profile cpu up -d -``` - -Pull the starter model, `gemma3:4b`, once the server is running: +For your own PostgreSQL (with the `vector` extension available; see [Managed PostgreSQL](/platform/self-hosting/reference-architectures#managed-postgresql)), add an overlay that points the app, realtime, and migrations at it and stops starting the bundled database. Save it as `external-db.yml`: -```bash -docker compose -f docker-compose.prod.yml -f docker-compose.ollama.yml --profile setup run --rm model-setup +```yaml +services: + simstudio: + environment: + DATABASE_URL: ${EXTERNAL_DATABASE_URL:?set EXTERNAL_DATABASE_URL in .env} + depends_on: !override + uploads-init: + condition: service_completed_successfully + redis: + condition: service_healthy + migrations: + condition: service_completed_successfully + realtime: + condition: service_healthy + realtime: + environment: + DATABASE_URL: ${EXTERNAL_DATABASE_URL:?set EXTERNAL_DATABASE_URL in .env} + depends_on: !override + redis: + condition: service_healthy + migrations: + condition: service_completed_successfully + migrations: + environment: + DATABASE_URL: ${EXTERNAL_DATABASE_URL:?set EXTERNAL_DATABASE_URL in .env} + depends_on: !reset {} + db: + profiles: [bundled-db] ``` -To pull another model, exec into the server for your profile: +Then add to `.env`: ```bash -# GPU profile -docker compose -f docker-compose.prod.yml -f docker-compose.ollama.yml --profile gpu exec ollama ollama pull llama3.2 - -# CPU profile -docker compose -f docker-compose.prod.yml -f docker-compose.ollama.yml --profile cpu exec ollama-cpu ollama pull llama3.2 +EXTERNAL_DATABASE_URL=postgresql://:@:5432/simstudio?sslmode=require +COMPOSE_FILE=docker-compose.prod.yml:external-db.yml ``` -#### Migrating from the previous Ollama stack - -The previous `docker-compose.ollama.yml` was a standalone stack with the fixed project name `sim-with-ollama`, so its database and models live in the `sim-with-ollama_postgres_data` and `sim-with-ollama_ollama_data` volumes. The overlay takes its project name from `docker-compose.prod.yml`, and started as-is it creates empty volumes instead. To keep your data: - -1. From the repository directory, stop the old stack without `-v`, so its volumes are kept. The old file is gone, so name the project instead: - - ```bash - docker compose -p sim-with-ollama down - ``` - -2. Add the old project name and database password to `.env`, so the overlay and the `sim-setup` CLI both resolve the same project and volumes. The old stack's password defaulted to `postgres` unless you set one: - - ```bash - COMPOSE_PROJECT_NAME=sim-with-ollama - POSTGRES_PASSWORD=postgres - OLLAMA_URL=http://ollama:11434 - ``` - -3. Start the stack with the overlay and your profile, as above. - -Ollama is no longer published on host port `11434`. Reach it with `docker compose exec`, as in the model pull commands above. - -## LM Studio - -Start [LM Studio's local server](https://lmstudio.ai/docs/developer/core/server), load a model, enable **Serve on Local Network**, and [configure API authentication](https://lmstudio.ai/docs/developer/core/authentication). Save these values beside your Compose file: - -```bash -VLLM_BASE_URL=http://host.docker.internal:1234 -VLLM_API_KEY=your_lm_studio_api_token -``` +`!override` needs Compose 2.24.4 or later. Keep `POSTGRES_PASSWORD` set to any value: the base file still requires it. With `COMPOSE_FILE` in `.env`, plain `docker compose` commands and `npx sim-setup update` apply both files. -Use a reachable host IP when needed. Sim accepts the server root or a `/v1` URL. Models appear with a `vllm/` prefix, which Sim removes before sending the model ID to LM Studio. +## Local models [#ollama] -Recreate the app using the file that started your installation: - -```bash -COMPOSE_FILE=docker-compose.prod.yml -# For a source-built stack, use docker-compose.local.yml. A stack running the -# Ollama overlay is a docker-compose.prod.yml install. -docker compose -f "$COMPOSE_FILE" up -d --force-recreate simstudio -``` +To run Ollama, LM Studio, or vLLM with this stack, see [Local models](/platform/self-hosting/local-models). ## The `sim-setup` CLI -Invoke commands as `npx sim-setup ` unless the package is installed globally. Run `doctor`, `config`, and the wizard from the configuration directory. Lifecycle commands discover running production/local Compose stacks, source checkouts, and Helm releases. Compose commands apply every file the stack was started with, such as the Ollama overlay. For a stopped stack they use `COMPOSE_FILE` from its `.env`, else `docker-compose.prod.yml` plus `docker-compose.override.yml` when that file exists. `update` prints the files it applies. Compose does not record profiles, so set `COMPOSE_PROFILES` in `.env` (for example `COMPOSE_PROFILES=cpu`) for a stack that uses them. +Run `npx sim-setup `. Run the wizard, `doctor`, and `config` from the configuration directory. Lifecycle commands find running Compose stacks, source checkouts, and Helm releases, and apply every Compose file a stack was started with. A stopped stack uses `COMPOSE_FILE` from its `.env`. Compose does not record profiles, so set `COMPOSE_PROFILES` in `.env` for a stack that uses them. | Command | Behavior | | --- | --- | -| `sim-setup` | Wizard. `--quick` uses defaults and asks essential questions; `--mode compose\|dev\|k8s` chooses the target; `--url ` sets a Compose install's public URL. Dev and Kubernetes modes require a source checkout. | -| `status` | Reports detected installations and health. | -| `logs` | Follows Compose logs or the Kubernetes app deployment. In dev mode, prints container log commands; the app runs in your terminal. | -| `start` / `stop` / `restart` | Starts, stops, or restarts Compose services. In dev mode, manages only PostgreSQL and Redis; start/stop the dev server yourself. For Kubernetes, prints port-forward or scale commands without applying them. | -| `update` | Pulls or rebuilds Compose images and applies them. Refuses dev and Kubernetes installs, which use git and `helm upgrade`. | -| `down` | Confirms before removing managed containers or uninstalling the Helm release. Compose/dev data volumes remain. | -| `reset` | Confirms before archiving env files and removing managed Compose/dev data. On Helm it uninstalls the release; PostgreSQL StatefulSet PVCs remain and must be deleted separately to erase data. | +| `sim-setup` | Wizard. `--quick` uses defaults; `--mode compose\|dev\|k8s` picks the target (dev and k8s need a source checkout: run `bun run sim-setup` from the repo root); `--url ` sets a Compose install's public URL. | +| `status` | Reports detected installations and their health. | +| `logs` | Follows Compose logs or the Kubernetes app Deployment. | +| `start` / `stop` / `restart` | Manages Compose services. For Kubernetes, prints the commands instead of running them. `restart` does not apply changed environment; recreate the containers. | +| `update` | Pulls the images for `SIM_VERSION` (or rebuilds a source stack) and recreates the services. `--yes` skips the prompt about uploads still inside an old app container. Refuses dev and Kubernetes installs. | +| `down` | Removes managed containers, or uninstalls the Helm release, after confirming. Data volumes remain. | +| `reset` | Archives env files and removes managed Compose data after confirming. On Helm it uninstalls the release; PostgreSQL PVCs remain. | | `config` | Reports configured capabilities and integrations. | -| `doctor` | Checks env files and reachable services. `--fix` writes supported repairs; `--json` emits structured findings. | -| `add ` | Configures `email`, `storage`, `sandbox`, `jobs`, `knowledge`, `knowledge-embeddings`, `chat`, `llm`, or `integration `. Requires one writable configuration; refuses ambiguous destinations and Helm releases. | -| `desktop` | Prints this deployment's installer/server links. `--url ` skips discovery; `--no-open` skips the browser-opening prompt. | - -`--dir ` works with every command and scopes standalone lifecycle commands to that installation. - -For Compose, `reset` archives `.env` beside the Compose file. For dev, Kubernetes, or no detected install, it archives `apps/sim/.env`, `apps/realtime/.env`, `packages/db/.env`, and root `.env`. Preserve any backups before intentionally removing volumes. - -`add` writes beside the Compose file or to `apps/sim/.env` on a source checkout. Recreate containers that read the change. To point both app and realtime at a different Redis, set `REDIS_URL` in `.env` and recreate both containers. For a source checkout, mirror shared values into `apps/realtime/.env`. `restart` alone does not apply changed container environment. Desktop discovery refuses configurations naming different origins; pass `--url` to choose. - -## Back up and update [#commands] - -For the default database role/name: - -```bash -docker compose -f docker-compose.prod.yml exec -T db pg_dump -U postgres simstudio > backup.sql -``` +| `doctor` | Checks env files and reachable services. `--fix` writes supported repairs; `--json` prints structured findings. | +| `add ` | Configures `email`, `storage`, `sandbox`, `jobs`, `knowledge`, `knowledge-embeddings`, `chat`, `llm`, or `integration ` in a writable `.env`. Refuses Helm releases. | +| `desktop` | Prints this deployment's desktop installer links. `--url ` skips discovery. | -Restore only to the intended database: +`--dir ` works with every command and scopes it to that installation. -```bash -docker compose -f docker-compose.prod.yml exec -T db psql -U postgres simstudio < backup.sql -``` - -Use your configured role/database if you changed `POSTGRES_*`. `-T` disables TTY allocation for redirected input/output. Compose stores database data in the `postgres_data` volume and local uploads in the `sim_uploads` volume; back up uploads and encryption keys separately. - -For an image update, change the pinned `SIM_VERSION` in `.env`, then: - -```bash -npx sim-setup update -``` - -Read [Upgrades](/platform/self-hosting/upgrades) before updating or restoring an existing installation. + + `add` and `doctor --fix` write `.env`; recreate the affected containers with `docker compose -f docker-compose.prod.yml up -d` to apply the change. + -## Related docs +## Back up and upgrade [#commands] -- [Environment variables](/platform/self-hosting/environment-variables) -- [Background jobs](/platform/self-hosting/background-jobs) -- [Security](/platform/self-hosting/security) +Back up the database, the `sim_uploads` volume, and `.env`. [Upgrades](/platform/self-hosting/upgrades) has the backup, update, and rollback commands. diff --git a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx index 068c8faeab8..83e2f852655 100644 --- a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx +++ b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx @@ -5,9 +5,9 @@ description: Deployment configuration, feature prerequisites, and limits import { Callout } from '@/components/ui/callout' -Configure variables in the env files or secret strategy for your deployment. Restart source processes or recreate containers/pods after changes; a running process does not reread credentials. +Set these in `.env` on Compose or through your [secret strategy](/platform/self-hosting/kubernetes#secret-stores) on Helm, then recreate the containers or pods; a running process does not reread them. Compose derives `DATABASE_URL` and `BETTER_AUTH_URL`, and Helm derives the database URL, `BETTER_AUTH_URL`, and the internal service URLs. [Docker](/platform/self-hosting/docker#production-setup) has a complete `.env` for a new installation. -Production Compose derives `DATABASE_URL` and `BETTER_AUTH_URL` on its service definitions, overriding values in `.env`. Use `POSTGRES_*` and `NEXT_PUBLIC_APP_URL` there. Helm constructs the database URL from its database values. See [Docker](/platform/self-hosting/docker) and [Kubernetes secret strategies](/platform/self-hosting/kubernetes#secret-stores). +Trigger.dev is a hosted-only job backend; leave the `TRIGGER_*` variables unset. ## Required @@ -19,29 +19,29 @@ Production Compose derives `DATABASE_URL` and `BETTER_AUTH_URL` on its service d | `ENCRYPTION_KEY` | Encryption key, exactly 64 hex characters (32 bytes): `openssl rand -hex 32`. A key in any other format leaves [account token sealing](/platform/self-hosting/security#account-token-sealing) off | | `INTERNAL_API_SECRET` | Internal API secret, at least 32 characters: `openssl rand -hex 32` | | `NEXT_PUBLIC_APP_URL` | Public app URL | -| `REDIS_URL` | Redis connection string (`redis://` or `rediss://`), shared by the app and realtime services. The app refuses to start without it; there is no PostgreSQL or in-memory fallback. See [Redis](/platform/self-hosting/redis) | +| `REDIS_URL` | `redis://` or `rediss://` URL, the same for the app and realtime. [Required](/platform/self-hosting/redis) | -`openssl rand -hex 32` prints 64 hex characters. Encryption keys require that format. The app skips its env schema validation; individual consumers can reject invalid values when first used. Realtime validates `BETTER_AUTH_SECRET` and `INTERNAL_API_SECRET` at boot and rejects values shorter than 32 characters. - - - Retain `ENCRYPTION_KEY` and `API_ENCRYPTION_KEY` across upgrades and restores. There is no supported in-place key rotation procedure; losing a key makes values encrypted with it unreadable — workspace and personal environment variables, stored provider API keys, MCP OAuth credentials, connected-account OAuth tokens, and deployment/chat secrets in the first case, user-generated Sim API keys in the second. Back them up separately from the database. - +The app does not validate its environment at startup; a malformed value fails where it is first used. Realtime rejects a `BETTER_AUTH_SECRET` or `INTERNAL_API_SECRET` shorter than 32 characters at boot. Keep the encryption keys for the life of the database; see [Secrets](/platform/self-hosting/security#secrets). ## Feature prerequisites and coordination [#strongly-recommended] | Variable | Description | |----------|-------------| | `API_ENCRYPTION_KEY` | Encrypts stored Sim API-key material; use exactly 64 hex characters (`openssl rand -hex 32`). When unset, legacy API keys can be stored in plain text; the key getter logs a warning when called | -| `CRON_SECRET` | Bearer token for the background job endpoints: `openssl rand -hex 32`. **Required whenever background jobs are enabled** — the Helm chart's default, and the chart will not render without it, unless it comes from `app.secrets.existingSecret` or External Secrets. See [Background jobs](/platform/self-hosting/background-jobs) | +| `CRON_SECRET` | Bearer token the scheduler sends to the job endpoints: `openssl rand -hex 32`. Required for [background jobs](/platform/self-hosting/background-jobs) | | `REDIS_TLS_SERVERNAME` | TLS SNI override. Required when `REDIS_URL` uses `rediss://` with a bare IP, or the app refuses to start | | `NEXT_PUBLIC_SOCKET_URL` | Public WebSocket URL. Proxied deployments default to the page origin; a localhost page uses port 3002. Set it for a separate realtime host. | | `TRUSTED_ORIGINS` | Comma-separated additional origins to trust for auth (apex + `www`, alias domains) | | `AUTH_TRUSTED_PROXIES` | Comma-separated reverse-proxy IPs/CIDRs so the client IP cannot be forged through `X-Forwarded-For` | -| `INTERNAL_API_BASE_URL` | Internal URL for server-side self-calls, e.g. `http://sim-app.simstudio.svc.cluster.local:3000`. Defaults to the public base URL. The Trigger.dev worker ignores it and uses the public app URL. | +| `INTERNAL_API_BASE_URL` | Internal URL for server-side self-calls, e.g. `http://sim-app.simstudio.svc.cluster.local:3000`. Defaults to the public base URL | +| `SOCKET_SERVER_URL` | Internal URL the app uses to reach realtime. Compose sets `http://realtime:3002` and Helm sets the realtime Service | +| `INTERNAL_JWT_SECRET` | Separate signing key for the app's internal tokens, at least 32 characters. Falls back to `INTERNAL_API_SECRET` | +| `LOG_LEVEL` | `DEBUG`, `INFO`, `WARN`, or `ERROR`. Production defaults to `ERROR`; `sim-setup` writes `INFO` | | `SIM_MCP_URL` | Public URL of the [Sim MCP server](/mcp/overview) when you serve it on its own host, e.g. `https://mcp.example.com/mcp`. Point that host at the app; Sim serves only the MCP endpoint and its OAuth metadata there, and stops serving `/api/mcp` on the app host so clients use one URL. Optional — defaults to `/api/mcp` | | `MCP_OAUTH_CLIENT_METADATA_DOCUMENT_ENABLED` | Set to `true` so Sim identifies itself to MCP OAuth servers that support it with a client ID metadata document, instead of registering a new client at each server. The server reads `/api/mcp/oauth/client-metadata`, so turn it on only when that HTTPS URL is reachable from the internet. Off by default on self-hosted deployments, and has no effect while the app URL is not HTTPS. See [MCP client registration](/agents/mcp#oauth-client-registration) | | `ENCRYPT_ACCOUNT_TOKENS` | Set to `false` to stop sealing connected-account OAuth tokens on write and during `migrate`. Sealing is on by default with a 64-hex `ENCRYPTION_KEY`; see [Account token sealing](/platform/self-hosting/security#account-token-sealing) | | `DATABASE_REPLICA_URL` | Read-replica connection string for log listing, audit logs, and dashboard aggregations. Falls back to the primary when unset | +| `DATABASE_URL_` | Separate connection string, and connection pool, for one workload: `CLEANUP`, `EXEC`, `SEARCH`, `BILLING`, or `AUTH` inside the app, and `REALTIME` for the realtime server. Each falls back to `DATABASE_URL`. See [Connections](/platform/self-hosting/scaling#connections) | ## AI providers @@ -64,9 +64,7 @@ Production Compose derives `DATABASE_URL` and `BETTER_AUTH_URL` on its service d Knowledge bases use an embedding model independent of the chat model. See [Knowledge bases](#knowledge-bases) for supported providers, local Ollama, and vector widths. -For provider-key rotation, configure `_1`, `_2`, and `_3` keys, such as `OPENAI_API_KEY_1` and `OPENAI_API_KEY_2`. OpenAI, Anthropic, Gemini, xAI, Kimi, Z.ai, Cohere, and Fireworks support numbered keys. - -For Ollama on the Docker host, use `OLLAMA_URL=http://host.docker.internal:11434` and ensure its server is reachable from the container. +For provider-key rotation, configure `_1`, `_2`, and `_3` keys, such as `OPENAI_API_KEY_1` and `OPENAI_API_KEY_2`. OpenAI, Anthropic, Gemini, xAI, Kimi, Z.ai, Cohere, and Fireworks support numbered keys. For Ollama, see [Local models](/platform/self-hosting/local-models). **Agent tool-call depth.** An Agent block keeps calling tools until the model answers, with no round-trip limit by default. With billing disabled there is also no execution timeout unless `EXECUTION_TIMEOUT_FREE` (sync) or `EXECUTION_TIMEOUT_ASYNC_FREE` (async) is set, so a looping agent keeps making paid model calls. Set `MAX_TOOL_ITERATIONS` (for example `MAX_TOOL_ITERATIONS=50`) to cap the model round trips per block, or set those timeouts to bound the whole run. @@ -115,12 +113,7 @@ For Ollama on the Docker host, use `OLLAMA_URL=http://host.docker.internal:11434 ### Self-hosted OpenAI-compatible endpoints -| Variable | Description | -|----------|-------------| -| `VLLM_BASE_URL` | OpenAI-compatible vLLM or LM Studio URL. Both the server root (`http://localhost:8000`) and versioned API URL (`http://localhost:8000/v1`) are accepted | -| `VLLM_API_KEY` | Optional bearer token for the vLLM or LM Studio endpoint | -| `LITELLM_BASE_URL` | LiteLLM proxy base URL | -| `LITELLM_API_KEY` | Optional bearer token for LiteLLM | +`VLLM_BASE_URL` and `VLLM_API_KEY` connect vLLM or LM Studio; `LITELLM_BASE_URL` and `LITELLM_API_KEY` connect a LiteLLM proxy. See [Local models](/platform/self-hosting/local-models). ## Knowledge bases @@ -146,13 +139,7 @@ For hosted models, Sim checks catalog-supported widths and falls back to the mod | `1536` | `text-embedding-3-small`, `text-embedding-3-large`, `gemini-embedding-001` | | `3072` | `text-embedding-3-large`, `gemini-embedding-001` | -For Compose or a source checkout, run `npx sim-setup add knowledge-embeddings` to choose OpenAI, Azure OpenAI, OpenRouter, Gemini, or Ollama and write its configuration. The three OpenAI-family transports share model/width choices. `npx sim-setup config` reports the family selected by `KB_EMBEDDING_MODEL`. For Helm, set the variables through chart values or your secret strategy. Run Ollama yourself; the setup command configures a connection, not an Ollama installation. - -The Embeddings block reads the same `OLLAMA_URL`. It lists the models on that server that report an -embedding capability, with the width each one emits where Ollama reports it, so a workflow can embed -locally without an API key. Ollama only began reporting capabilities in 0.5 — against an older -server nothing can be filtered, so the list includes chat models and labels none of them with a -width. Check what you pick there, or upgrade Ollama. +On Compose, `npx sim-setup add knowledge-embeddings` chooses a provider and writes its configuration. The Embeddings block lists the embedding models on `OLLAMA_URL`; servers older than Ollama 0.5 report no capabilities, so their list also includes chat models. ## Login providers @@ -188,7 +175,7 @@ Who may sign up and sign in — the allowlists, blocklists, `REGISTRATION_MODE`, | `E2B_FUNCTION_TEMPLATE_ID` | Immutable `