File size: 3,945 Bytes
f589dab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
version: "3.9"

# Spins up: Qdrant, Memgraph, Redpanda, Redis Stack
# Usage: docker compose up -d
# Backend: uvicorn main:app --host 0.0.0.0 --port 7860

services:

  # ── Qdrant: High-performance vector database ──────────────────────────────
  qdrant:
    image: qdrant/qdrant:v1.12.0
    container_name: fact_qdrant
    ports:
      - "6333:6333"   # REST API
      - "6334:6334"   # gRPC API
    volumes:
      - qdrant_data:/qdrant/storage
    environment:
      QDRANT__SERVICE__HTTP_PORT: 6333
      QDRANT__SERVICE__GRPC_PORT: 6334
      QDRANT__LOG_LEVEL: INFO
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:6333/healthz"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  # ── Memgraph: In-memory graph database (Cypher-compatible) ───────────────
  memgraph:
    image: memgraph/memgraph:2.19.0
    container_name: fact_memgraph
    ports:
      - "7687:7687"   # Bolt protocol (same as Neo4j)
      - "7444:7444"   # Memgraph Lab UI
    volumes:
      - memgraph_data:/var/lib/memgraph
    command: >
      --storage-mode=IN_MEMORY_TRANSACTIONAL
      --log-level=WARNING
      --query-execution-timeout-sec=30
    healthcheck:
      test: ["CMD", "echo", "RETURN 1;" , "|", "mgconsole"]
      interval: 15s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  # ── Redpanda: Kafka-compatible streaming platform (no JVM) ───────────────
  redpanda:
    image: redpandadata/redpanda:v24.2.0
    container_name: fact_redpanda
    ports:
      - "9092:9092"   # Kafka API
      - "9644:9644"   # Admin API
      - "8081:8081"   # Schema registry
      - "8082:8082"   # HTTP Proxy
    volumes:
      - redpanda_data:/var/lib/redpanda/data
    command:
      - redpanda start
      - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:9093
      - --advertise-kafka-addr internal://redpanda:9092,external://localhost:9093
      - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:18082
      - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:18081
      - --rpc-addr redpanda:33145
      - --advertise-rpc-addr redpanda:33145
      - --smp 1
      - --memory 1G
      - --mode dev-container
      - --overprovisioned
    healthcheck:
      test: ["CMD-SHELL", "rpk cluster health | grep -E 'Healthy:.+true'"]
      interval: 15s
      timeout: 10s
      retries: 10
    restart: unless-stopped

  # ── Redis Stack: Redis + RedisJSON + RedisSearch ──────────────────────────
  redis:
    image: redis/redis-stack:7.4.0-v0
    container_name: fact_redis
    ports:
      - "6379:6379"   # Redis
      - "8001:8001"   # RedisInsight UI
    volumes:
      - redis_data:/data
    environment:
      REDIS_ARGS: "--save 60 1 --loglevel warning"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  # ── Fact Engine Backend ───────────────────────────────────────────────────
  backend:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: fact_backend
    ports:
      - "7860:7860"
    environment:
      - REDIS_URL=redis://redis:6379
      - QDRANT_URL=http://qdrant:6333
      - MEMGRAPH_HOST=memgraph
      - MEMGRAPH_PORT=7687
      - REDPANDA_BROKERS=redpanda:9092
      - GROQ_API_KEY=${GROQ_API_KEY}
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - X_BEARER_TOKEN=${X_BEARER_TOKEN}
      - PORT=7860
    depends_on:
      qdrant:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: unless-stopped

volumes:
  qdrant_data:
  memgraph_data:
  redpanda_data:
  redis_data: