Documentación
Self-hosted (Enterprise)
Run the full Tovriq stack inside your own infrastructure with one command, under a signed license.
Esta página aún no está disponible en tu idioma, así que se muestra en inglés.
The self-hosted tier runs the whole stack on your own servers. Vault content, the MCP gateway and background jobs never leave your network, and with the optional Ollama service no data goes to an external AI provider either.
Self-hosting is part of Enterprise & Self-Hosted (from $2,000/year). Contact sales for a license key.
What runs
| Service | Purpose |
|---|---|
preflight | One-shot: checks .env.enterprise before any other service starts |
app | Dashboard, API, MCP gateway (/api/mcp) and browser-extension API (/api/extension/*) |
migrate | One-shot: applies the database migrations (prisma migrate deploy) before app starts |
postgres | PostgreSQL 16 (app database plus a separate inngest database) |
seaweedfs | S3-compatible storage for avatars and storage mirrors |
seaweedfs-init | One-shot: creates the avatars and context-vaults buckets |
inngest | Background jobs: builds, delta sync, allowance renewals, temp cleanup |
ollama | Optional (--profile ollama): fully offline models |
Install
cp .env.enterprise.example .env.enterprise # replace every CHANGE_ME value
docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise up -d
Generate secrets with openssl rand -base64 32 (auth, encryption) and openssl rand -hex 32 (Inngest signing key). Back up CONTEXT_OS_ENCRYPTION_KEY: it protects AI keys, storage credentials and encrypted vault content.
Every service waits for preflight, which checks .env.enterprise with the app's own startup rules. While a CHANGE_ME is left anywhere, a secret is too weak or MAIL_FROM is not an address, up stops there and nothing else starts, so Postgres never creates its database with a placeholder password. docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise logs preflight lists what to fix.
License
The Docker Compose file marks the node as self-hosted (CONTEXT_OS_SELF_HOSTED=true). Put the key you received in CONTEXT_OS_LICENSE_KEY. It is an Ed25519-signed license that names the highest plan the node may run (usually ENTERPRISE_NODE), the licensed seats and the expiry date. CONTEXT_OS_DEFAULT_PLAN picks the plan the node runs as, up to the licensed one. Billing then shows Enterprise · Licensed and no checkout is needed.
Without a valid key the node runs as a regular Free installation: leave CONTEXT_OS_LICENSE_KEY empty for that. A CHANGE_ME left there stops the preflight like any other placeholder.
AI keys and token limits
How much AI work a node allows depends on whose key or model does it:
| AI source | Set in | Token limit |
|---|---|---|
| A cloud AI key for the whole node (Gemini, OpenAI or Anthropic) | .env.enterprise | 10 million tokens a month for each account and each organization |
| A vault's own key (BYOK), on a licensed node | The vault's AI settings | None |
| Local models: Ollama, or an OpenAI-compatible server such as vLLM | .env.enterprise (next section) | None |
A node-wide cloud key is GOOGLE_GENERATIVE_AI_API_KEY, OPENAI_API_KEY or ANTHROPIC_API_KEY (or CONTEXT_AI_API_KEY, which works for any provider). Everything done with it is metered: building vaults, voice notes, the Contextual Magnet and Vault Chat. On the ENTERPRISE_NODE plan, each person's own vaults share 10,000,000 tokens a month, and each organization's vaults share another 10,000,000. The count starts again on the first day of every month (UTC), unused tokens do not roll over, and premium models (Pro / Opus / Sonnet class) count 4× their usage.
When an allowance is used up, AI work for that account or organization stops until the next month; the vaults themselves stay available to people and agents. A build distills what fits and keeps the rest staged, encrypted, for 7 days. The account, or the organization's owners and admins, get a notification at 80 % and when the tokens run out. To continue sooner, a platform admin can add one-off tokens under Admin → Users or Admin → Organizations (Grant bonus tokens), or the vault can switch to its own key or a local model.
The node's own key has two more guards: CONTEXT_OS_PLATFORM_DAILY_TOKEN_LIMIT caps what the whole node spends with it in one UTC day, and CONTEXT_OS_PLATFORM_AI_PAUSED=1 pauses it at once. Neither limits a vault's own key or a local model.
Offline models with Ollama
docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise \
--profile ollama up -d
docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise \
exec ollama ollama pull llama3.1
Then set CONTEXT_AI_PROVIDER="ollama", CONTEXT_AI_BASE_URL="http://ollama:11434/v1" and CONTEXT_AI_MODEL="llama3.1" in .env.enterprise and run up -d again. Local models do not count against the token allowance. A node-wide OpenAI-compatible server such as vLLM counts as local too: set CONTEXT_AI_PROVIDER="openai-compatible", its URL in CONTEXT_AI_BASE_URL and its model in CONTEXT_AI_MODEL.
Teams and access
Self-hosted vaults use the same folder roles as Team: every folder's allowed roles (Owner, Admin, Member) control what each teammate, and each agent connected through MCP, can read. Expiring, folder-scoped share links give freelancers temporary access.
The first account created on a node becomes its platform admin. After that, people can sign up only with a pending invitation, or with an e-mail address in one of the domains listed in CONTEXT_OS_SIGNUP_DOMAINS (comma-separated, e.g. acme.com). Admins can always create accounts from Admin → Users.
Network and security defaults
- The app and the S3 endpoint listen on
127.0.0.1only. Put a TLS reverse proxy in front of the app (and ofS3_PUBLIC_ENDPOINT). To publish them directly instead, setAPP_BIND_ADDRESS/S3_BIND_ADDRESSto0.0.0.0. - Your proxy must append the client address to
X-Forwarded-For. Per-IP rate limits use the right-most entry; with more than one proxy hop, setCONTEXT_OS_TRUSTED_PROXY_HOPS. - Storage and AI endpoints that people configure in vaults may reach only the private hosts listed in
CONTEXT_OS_PRIVATE_HOST_ALLOWLIST(comma-separated hosts, IPs or CIDRs). The compose file allows the bundledollamaonly; addseaweedfsonly if people mirror vaults to the bundled bucket, and list LAN services such as a vLLM server yourself. Cloud metadata and link-local addresses are always refused. Vault mirrors go to a private GitHub repository or to S3-compatible storage. - Nothing starts while a
CHANGE_MEplaceholder is left anywhere in.env.enterprise(the license key included), or when the auth secret or encryption key is shorter than 32 characters or too repetitive, the Inngest signing key is shorter than 64 hex characters orMAIL_FROMis not an address: thepreflightservice refuses before Postgres creates its database, and the app runs the same checks when it starts. - The Inngest dashboard on
127.0.0.1:8288and the SeaweedFS admin page on127.0.0.1:9001have no sign-in: whoever reaches them can run and replay background jobs or manage the stored files. The compose file publishes them on127.0.0.1only. Reach them through an SSH tunnel, and never publish them on another interface. GET /api/healthanswers 503 while the database is unreachable, so your orchestrator can restart or hold traffic.
Backup
A node keeps its state in three places. Back them up together, on a schedule and before every upgrade:
| What | Where | Holds |
|---|---|---|
| Configuration | .env.enterprise | Every secret, the license key and CONTEXT_OS_ENCRYPTION_KEY |
| Databases | postgres_data volume | Accounts, vaults (their content encrypted), access keys and the saved background-job queue |
| Object storage | seaweedfs_data volume | Avatars, and vault mirrors that use the bundled bucket |
A database backup cannot be read without CONTEXT_OS_ENCRYPTION_KEY: keep .env.enterprise in a secret manager, apart from the dumps. Models in ollama_data can be pulled again and need no backup. The commands below write the backups outside the release folder, which is what the images are built from.
# Shorthand for the commands below
compose() {
docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise "$@"
}
# Outside the release folder, readable by you only
backups="$HOME/tovriq-backups"
mkdir -p "$backups" && chmod 700 "$backups"
# Databases (the node keeps running)
compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -Fc "$POSTGRES_DB"' \
> "$backups/tovriq-app.dump"
compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -Fc inngest' \
> "$backups/tovriq-jobs.dump"
# Object storage (stopped for a moment, so the archive is consistent)
compose stop seaweedfs
compose run --rm --no-deps -T --entrypoint tar seaweedfs czf - -C /data . \
> "$backups/tovriq-files.tgz"
compose start seaweedfs
To restore, on the same server or a new one, put the release and your .env.enterprise in place first. Each step replaces the whole database or volume with the backup:
compose() {
docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise "$@"
}
backups="$HOME/tovriq-backups"
compose up -d --wait postgres seaweedfs
compose stop app inngest seaweedfs
# Databases: each one is dropped and recreated from its dump
restore='pg_restore -U "$POSTGRES_USER" -d postgres --clean --if-exists --create'
compose exec -T postgres sh -c "$restore --exit-on-error" < "$backups/tovriq-app.dump"
compose exec -T postgres sh -c "$restore --exit-on-error" < "$backups/tovriq-jobs.dump"
# Object storage: the volume is emptied and filled from the archive
compose run --rm --no-deps -T --entrypoint sh seaweedfs \
-c 'find /data -mindepth 1 -delete && tar xzf - -C /data' \
< "$backups/tovriq-files.tgz"
compose up -d
A database restore stops with an error and changes nothing while app or inngest is still connected, so stop them first as shown.
Upgrade
- Take a backup (above).
- Replace the source with the new release and keep your
.env.enterprise. Compare it with the new.env.enterprise.exampleand add any setting that is new. - Rebuild and restart:
compose() {
docker compose -f docker-compose.enterprise.yml --env-file .env.enterprise "$@"
}
compose up -d --build
compose ps # app is "healthy" once it is up
compose logs preflight migrate app # if it is not
The preflight check runs first, then the migrate service applies the new database migrations, and app starts only after both succeed, so expect a short interruption while the containers restart. GET /api/health answers 200 again when the node is ready.
Migrations only move forward. To return to the previous release, restore the backup from step 1 and start that release.
Notes
PUBLIC_URLis compiled into the app. Rebuild withup -d --buildafter changing it.- Sign-up sends a verification email. Set
RESEND_API_KEY, or pointMAIL_HOST(plus optionalMAIL_PORT,MAIL_USER,MAIL_PASS) at an SMTP relay. With neither, emails, including verification links, are printed to theapplogs. - Push notifications are optional and off until you set
VAPID_PUBLIC_KEYandVAPID_PRIVATE_KEYin.env.enterprise(the example file has a one-line command that makes the pair) and runup -dagain. Keep the pair: browsers that turned push on are tied to it. They need the node onhttps://and outbound access to the browsers' push services (Google, Mozilla, Apple, Microsoft). Until then Settings → Notifications says push is not set up, and nothing else changes. - A self-hosted node sells nothing: it has no checkout and no payment setting. Plans come from your license key.
S3_PUBLIC_ENDPOINTmust be reachable from users' browsers, because avatar uploads use presigned URLs.- Background jobs: Inngest keeps its queue in memory and saves it to the
inngestdatabase at regular intervals. A job queued just before theinngestcontainer stops or crashes can be lost; request that build again. - Every container keeps at most five log files of 10 MB each.
- The interactive API reference (
/api/docs) is off in production. SetCONTEXT_OS_API_DOCS=1to serve it to your integrators.
¿Sigues atascado? Contacta con soporte y te ayudaremos.