# n8n + Ollama + Qdrant: stack recipe from https://archestack.com/stacks/n8n-ollama-qdrant/
# Started and checked 2026-11-19 on ubuntu-lan (x86-64, CPU only, Docker 29.9.2, Compose v5.6.1). Images are pinned: bump them on purpose.
services:
  db:
    image: postgres:17-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: n8n
      POSTGRES_DB: n8n
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?run the .env line first}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"]
      interval: 5s
      retries: 12
  ollama:
    image: ollama/ollama:0.40.16
    restart: unless-stopped
    volumes:
      - ollama:/root/.ollama
    healthcheck:
      test: ["CMD", "ollama", "list"]
      interval: 10s
      retries: 12
  qdrant:
    image: qdrant/qdrant:v1.20.2
    restart: unless-stopped
    volumes:
      - qdrant:/qdrant/storage
  n8n:
    image: n8nio/n8n:2.48.6
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
      ollama:
        condition: service_healthy
      qdrant:
        condition: service_started
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: db
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_DATABASE: n8n
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY:?run the .env line first}
      N8N_DIAGNOSTICS_ENABLED: "false"
    volumes:
      - n8n:/home/node/.n8n
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://localhost:5678/healthz | grep -q ok"]
      interval: 5s
      retries: 60
      start_period: 20s
volumes:
  pgdata:
  ollama:
  qdrant:
  n8n:
