Aller au contenu

Deployment

Ce contenu n’est pas encore disponible dans votre langue.

Cortex ships as a Docker Compose stack. This page covers the default deployment, the environment variables you need to set, and recommendations for running in production.


The docker-compose.example.yml defines nine services:

ServiceImageDefault portPurpose
surrealdbsurrealdb/surrealdb:v2.1.78000Graph + relational database
postgrespostgres:16-alpine5432Auth, audit trail, documents, provider credentials
meilisearchgetmeili/meilisearch:v1.127700Full-text search engine
miniominio/minio:latest9000 / 9001S3-compatible object storage
minio-initminio/mc:latestInit container: creates the storage bucket
ollamaollama/ollama:latest11434Local embeddings (bge-m3) and optional LLM
cortex_apibuilt from deploy/Dockerfile.api9096REST API
cortex_mcpbuilt from deploy/Dockerfile.mcp3001MCP server
cortex_uibuilt from cortex/ui/Dockerfile8080Web UI

All services use health checks. cortex_api waits for SurrealDB, PostgreSQL, MeiliSearch, MinIO and Ollama to be healthy before starting. cortex_mcp waits for cortex_api and Ollama.


VariablePurpose
SURREAL_USERSurrealDB root username
SURREAL_PASSSurrealDB root password
PG_PASSWORDPostgreSQL password
MEILI_MASTER_KEYMeiliSearch master API key
S3_ACCESS_KEYMinIO (S3) access key
S3_SECRET_KEYMinIO (S3) secret key
ENCRYPTION_KEYAES-256-GCM key for provider credential encryption (base64, 32 bytes)
VariableDefaultPurpose
SURREAL_NScortexSurrealDB namespace
SURREAL_DBcortexSurrealDB database name
PG_DATABASEcortexPostgreSQL database name
PG_USERcortexPostgreSQL username
S3_BUCKETcortexMinIO bucket name
CORTEX_API_KEY(empty)API key for REST/MCP authentication
CORS_ORIGINhttp://localhost:8080Allowed CORS origin for REST API
MCP_CORS_ORIGINShttps://claude.ai,https://chatgpt.comAllowed CORS origins for MCP server
OLLAMA_EMBED_MODELbge-m3Ollama embedding model
OLLAMA_LLM_MODELmistralOllama LLM model (for optional local inference)
API_PORT9096REST API port
MCP_PORT3001MCP server port
UI_PORT8080Web UI port
ALLOWED_EMAILS(empty)Comma-separated email whitelist for JWT auth
SUPABASE_JWT_SECRET(empty)JWT verification secret for Supabase auth

ResourceMinimumRecommended
CPU4 cores8 cores
RAM8 GB16 GB
Disk20 GB50+ GB (depends on catalogue size and embeddings)

Ollama with the bge-m3 embedding model is the most memory-intensive component. If you do not need local embeddings, you can remove the Ollama service and save resources.


The Docker Compose stack does not include TLS. For production, put a reverse proxy in front:

Internet -> [nginx/Caddy/Traefik with TLS] -> cortex_api:9096
-> cortex_mcp:3001
-> cortex_ui:8080

By default, all services except the UI bind to 127.0.0.1. The UI binds to 0.0.0.0:8080. In production, bind the UI to 127.0.0.1 as well and serve it through the reverse proxy.

  • Generate ENCRYPTION_KEY with openssl rand -base64 32.
  • Generate CORTEX_API_KEY with openssl rand -hex 32.
  • Use a secrets manager (Vault, AWS Secrets Manager, etc.) or Docker secrets instead of plain .env files in production.

Add resource limits to your Docker Compose services:

deploy:
resources:
limits:
memory: 2G
cpus: "1.0"

SurrealDB data is stored in a Docker volume (surreal_data). Back up via the HTTP export endpoint:

Terminal window
curl -X GET http://localhost:8000/export \
-u "root:YOUR_PASS" \
-H "surreal-ns: cortex" \
-H "surreal-db: cortex" \
-o cortex-surreal-backup.surql
Terminal window
docker compose exec postgres pg_dump -U cortex cortex > cortex-pg-backup.sql

Use the MinIO client (mc) to mirror the bucket:

Terminal window
mc alias set local http://localhost:9000 ACCESS_KEY SECRET_KEY
mc mirror local/cortex ./backup/minio-cortex

For production, automate backups at least twice daily. Store backups off-host (S3-compatible remote, separate server, etc.).


  1. Pull the latest code: git pull
  2. Rebuild images: docker compose -f docker-compose.example.yml build
  3. Restart: docker compose -f docker-compose.example.yml up -d

Data volumes persist across rebuilds. Check the CHANGELOG for migration notes before upgrading.