File size: 5,681 Bytes
1e732dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9699bea
1e732dd
 
 
 
9699bea
 
1e732dd
 
 
 
 
 
 
 
 
 
 
 
9699bea
1e732dd
 
9699bea
 
 
 
 
 
 
 
 
 
 
 
 
1e732dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696f787
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1e732dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# ===========================================================================
# MediGuard AI — Docker Compose (development / CI)
# ===========================================================================
# Usage:
#   docker compose up -d          — start all services
#   docker compose down -v        — stop and remove volumes
#   docker compose logs -f api    — follow API logs
# ===========================================================================

services:
  # -----------------------------------------------------------------------
  # Application
  # -----------------------------------------------------------------------
  api:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    container_name: mediguard-api
    ports:
      - "${API_PORT:-8000}:8000"
    env_file: .env
    environment:
      - POSTGRES__HOST=postgres
      - OPENSEARCH__HOST=opensearch
      - OPENSEARCH__PORT=9200
      - REDIS__HOST=redis
      - REDIS__PORT=6379
      - OLLAMA__BASE_URL=http://ollama:11434
      - LANGFUSE__HOST=http://langfuse:3000
    depends_on:
      postgres:
        condition: service_healthy
      opensearch:
        condition: service_healthy
      redis:
        condition: service_healthy
    volumes:
      - ./data/medical_pdfs:/app/data/medical_pdfs:ro
    restart: unless-stopped

  gradio:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    container_name: mediguard-gradio
    command: python -m src.gradio_app
    ports:
      - "${GRADIO_PORT:-7860}:7860"
    environment:
      - MEDIGUARD_API_URL=http://api:8000
    depends_on:
      - api
    restart: unless-stopped

  # -----------------------------------------------------------------------
  # Backing services
  # -----------------------------------------------------------------------
  postgres:
    image: postgres:16-alpine
    container_name: mediguard-postgres
    environment:
      POSTGRES_DB: ${POSTGRES__DATABASE:-mediguard}
      POSTGRES_USER: ${POSTGRES__USER:-mediguard}
      POSTGRES_PASSWORD: ${POSTGRES__PASSWORD:-mediguard_secret}
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    volumes:
      - pg_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U mediguard"]
      interval: 5s
      timeout: 3s
      retries: 10
    restart: unless-stopped

  opensearch:
    image: opensearchproject/opensearch:2.11.1
    container_name: mediguard-opensearch
    environment:
      - discovery.type=single-node
      - DISABLE_SECURITY_PLUGIN=true
      - plugins.security.disabled=true
      - "OPENSEARCH_JAVA_OPTS=-Xms256m -Xmx256m"
      - bootstrap.memory_lock=true
    ulimits:
      memlock: { soft: -1, hard: -1 }
      nofile: { soft: 65536, hard: 65536 }
    ports:
      - "${OPENSEARCH_PORT:-9200}:9200"
    volumes:
      - os_data:/usr/share/opensearch/data
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:9200/_cluster/health || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 24
    restart: unless-stopped

  # opensearch-dashboards: disabled by default — uncomment if you need the UI
  # opensearch-dashboards:
  #   image: opensearchproject/opensearch-dashboards:2.11.1
  #   container_name: mediguard-os-dashboards
  #   environment:
  #     - OPENSEARCH_HOSTS=["http://opensearch:9200"]
  #     - DISABLE_SECURITY_DASHBOARDS_PLUGIN=true
  #   ports:
  #     - "${OS_DASHBOARDS_PORT:-5601}:5601"
  #   depends_on:
  #     opensearch:
  #       condition: service_healthy
  #   restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: mediguard-redis
    ports:
      - "${REDIS_PORT:-6379}:6379"
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 10
    restart: unless-stopped

  ollama:
    image: ollama/ollama:latest
    container_name: mediguard-ollama
    ports:
      - "${OLLAMA_PORT:-11434}:11434"
    volumes:
      - ollama_data:/root/.ollama
    restart: unless-stopped
    # Uncomment for GPU support:
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: 1
    #           capabilities: [gpu]

  airflow:
    image: apache/airflow:2.8.2
    container_name: mediguard-airflow
    environment:
      - AIRFLOW__CORE__LOAD_EXAMPLES=false
      - AIRFLOW__CORE__EXECUTOR=LocalExecutor
      - AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://${POSTGRES__USER:-mediguard}:${POSTGRES__PASSWORD:-mediguard_secret}@postgres:5432/${POSTGRES__DATABASE:-mediguard}
    command: standalone
    ports:
      - "${AIRFLOW_PORT:-8080}:8080"
    volumes:
      - ./airflow/dags:/opt/airflow/dags:ro
      - ./data/medical_pdfs:/app/data/medical_pdfs:ro
      - .:/app:ro
    working_dir: /app
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped

  # -----------------------------------------------------------------------
  # Observability
  # -----------------------------------------------------------------------
  langfuse:
    image: langfuse/langfuse:2
    container_name: mediguard-langfuse
    environment:
      - DATABASE_URL=postgresql://mediguard:mediguard_secret@postgres:5432/langfuse
      - NEXTAUTH_URL=http://localhost:3000
      - NEXTAUTH_SECRET=mediguard-langfuse-secret-change-me
      - SALT=mediguard-langfuse-salt-change-me
    ports:
      - "${LANGFUSE_PORT:-3000}:3000"
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped

volumes:
  pg_data:
  os_data:
  redis_data:
  ollama_data: