Cogitator
Deployment

Docker Deployment

Run Cogitator with Docker Compose — PostgreSQL, Redis, Ollama, and production container setup.

Infrastructure Services

The Cogitator repository ships a docker-compose.yml with the three services agents usually need: PostgreSQL with pgvector for memory storage, Redis for caching, distributed state and job queues, and Ollama for local LLM inference.

docker compose up -d
# or, from any directory below the compose file:
cogitator up      # runs `docker compose up -d` when there is no assistant cogitator.yml here
cogitator down    # `docker compose down`; add -v to delete the volumes

cogitator up starts an assistant when the current directory has an assistant cogitator.yml (a runtime config such as the one create-cogitator-app generates does not count); otherwise it looks for docker-compose.yml / compose.yml in the current directory and up to five parents and starts those services (--pull pulls images first, --no-detach runs in the foreground).

ServiceImagePortPurpose
PostgreSQLpgvector/pgvector:pg165432Vector memory, agent state
Redisredis:7-alpine6379Cache, events, job queues
Ollamaollama/ollama:latest11434Local LLM runtime
ollama-initollama/ollama:latest—One-shot: pulls nomic-embed-text-v2-moe and llama3.2:3b

Docker Compose Configuration

services:
  postgres:
    image: pgvector/pgvector:pg16
    environment:
      POSTGRES_USER: cogitator
      POSTGRES_PASSWORD: cogitator_dev
      POSTGRES_DB: cogitator
    ports:
      - '5432:5432'
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U cogitator -d cogitator']
      interval: 5s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    ports:
      - '6379:6379'
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 5s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  ollama:
    image: ollama/ollama:latest
    ports:
      - '11434:11434'
    volumes:
      - ollama_data:/root/.ollama
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    restart: unless-stopped

volumes:
  postgres_data:
  redis_data:
  ollama_data:

docker/postgres/init.sql enables the vector and uuid-ossp extensions on first start.

Environment Variables

Create a .env file in your project root:

DATABASE_URL=postgresql://cogitator:cogitator_dev@localhost:5432/cogitator
REDIS_URL=redis://localhost:6379
OLLAMA_URL=http://localhost:11434

OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...

@cogitator-ai/config maps OLLAMA_URL (or OLLAMA_HOST) and the provider API keys onto llm.providers automatically. DATABASE_URL and REDIS_URL are conventions for your own code — pass them to the memory adapters or Redis client you create (the cogitator init templates and the built-in sqlQuery tool read DATABASE_URL):

import { PostgresAdapter } from '@cogitator-ai/memory';

const memory = new PostgresAdapter({
  provider: 'postgres',
  connectionString: process.env.DATABASE_URL!,
});

Production Dockerfile

cogitator deploy generates a Dockerfile, a Compose stack and preflight checks for you, see Deploy Package. Projects from create-cogitator-app --deploy docker have it at their root. For a pnpm project with a TypeScript server it looks like this, and a Dockerfile you maintain yourself can follow the same shape:

# syntax=docker/dockerfile:1
FROM node:24-alpine AS base
WORKDIR /app
RUN corepack enable

FROM base AS builder
RUN apk add --no-cache python3 make g++
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm prune --prod --ignore-scripts

FROM base AS runtime
RUN apk add --no-cache tini && chown node:node /app
ENV NODE_ENV=production PORT=3000
COPY --from=builder --chown=node:node /app ./
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s CMD wget -q --spider http://127.0.0.1:3000/api/health || exit 1
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node","dist/index.js"]

The builder has the toolchain native dependencies compile with and keeps the package store in a BuildKit cache, the runtime stage keeps only production dependencies, runs as the unprivileged node user, and tini forwards signals and reaps child processes such as MCP servers.

The server adapters expose GET /health and GET /ready under their base path (/cogitator by default):

  • /health is a liveness probe: it verifies the HTTP process is running and responding without checking external backends. Use it for container orchestrator restarts, such as Docker's HEALTHCHECK.
  • /ready is a readiness probe: it verifies connectivity to configured dependencies (such as the memory adapter) and returns HTTP 200 when ready, or HTTP 503 when a dependency check fails or times out. Use it for load balancers and traffic routing so unready instances do not receive requests.

Probe 127.0.0.1 rather than localhost: in Alpine images localhost resolves to the IPv6 ::1 first, which a server listening on 0.0.0.0 refuses.

Ollama in the Deployed Stack

When the project's models run on a local Ollama (an ollama/... model that is not Ollama Cloud, or memory.embedding with provider: ollama), the Compose stack cogitator deploy generates runs Ollama next to the app. The ollama service keeps the models in the ollama-data volume, and a one-shot ollama-pull service pulls the chat and embedding models on the first start, before the app starts. The app reaches it at http://ollama:11434 through COGITATOR_OLLAMA_BASE_URL, OLLAMA_BASE_URL, OLLAMA_URL and OLLAMA_HOST. With llm.defaultProvider: ollama a model needs no ollama/ prefix (defaultModel: qwen3:8b), and the pulls use the bare name either way.

cogitator.yml
llm:
  defaultModel: ollama/qwen3:8b
memory:
  embedding:
    provider: ollama
    baseUrl: ${OLLAMA_BASE_URL:-http://localhost:11434}
deploy:
  ollama:
    gpu: true # reserve the NVIDIA GPUs of the host
cogitator deploy                     # the first start downloads qwen3:8b and nomic-embed-text
cogitator deploy logs ollama-pull    # watch the download
cogitator deploy logs -f             # every service of the stack
cogitator deploy logs app -n 200     # the last 200 lines of the app

Each role keeps an Ollama URL that points beyond this machine: a chat model on a GPU box stays there while the embeddings run in the container, as long as memory.embedding.baseUrl follows a variable of its own such as ${OLLAMA_EMBEDDING_URL:-http://localhost:11434}. deploy.ollama.models replaces the detected list (models agents name in code are not detected), deploy.services.ollama: false reaches the Ollama of the Docker host through host.docker.internal instead. cogitator deploy destroy keeps the volume, so the next deploy finds the models.

GPU and CPU-Only Mode

The default compose file reserves NVIDIA GPUs for Ollama. On Apple Silicon, run Ollama natively:

brew install ollama && ollama serve
docker compose up -d postgres redis

Without a GPU, use the CPU compose variant (no GPU reservation; pulls nomic-embed-text instead of the MoE embedding model) and smaller models:

docker compose -f docker-compose.cpu.yml up -d
docker compose exec ollama ollama pull llama3.2:3b

Production Checklist

  • External PostgreSQL with backups, connection pooling (PgBouncer), and pgvector
  • Redis Cluster or managed Redis (ElastiCache, Upstash) for HA — see Redis
  • Dedicated GPU server for Ollama, or cloud providers (OpenAI, Anthropic, Google)
  • Reverse proxy (nginx, Caddy) with TLS termination
  • Secrets management via Vault, AWS SSM, or Kubernetes secrets
  • Health checks on all services to enable orchestrator restarts

On this page