๐Ÿ“ฆ EqualifyEverything / equalify-reflow

๐Ÿ“„ docker-compose.dev.yml ยท 257 lines
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257# Equalify Reflow - Development Override Configuration
# This file adds Floci (local AWS emulator) and development-specific configurations
# Usage: docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

services:
  # Floci - Local AWS emulator for development (replaces LocalStack)
  # ~72 MB image, ~26 ms startup, MIT licensed, S3 + CloudWatch + friends
  floci:
    image: hectorvent/floci:1.5.3
    container_name: equalify-reflow-floci
    restart: unless-stopped
    ports:
      - "4566:4566"
    environment:
      - FLOCI_DEFAULT_REGION=us-east-1
      - FLOCI_STORAGE_MODE=persistent
      - FLOCI_STORAGE_PERSISTENT_PATH=/app/data
      - FLOCI_HOSTNAME=floci
    volumes:
      - floci-data:/app/data
    healthcheck:
      # Floci has no dedicated /health endpoint; GET / returns 200 with
      # ListAllMyBucketsResult XML and is cheap + deterministic.
      test: ["CMD-SHELL", "curl -sf http://localhost:4566/ || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - equalify-network

  # Floci init sidecar - creates S3 buckets + CORS/policy/versioning/lifecycle.
  # Runs once after Floci reports healthy, then exits. boto3/awscli read
  # AWS_ENDPOINT_URL automatically so the init script uses plain `aws`
  # commands against Floci.
  floci-init:
    image: amazon/aws-cli:latest
    container_name: equalify-reflow-floci-init
    entrypoint: ["/bin/sh", "/init-aws.sh"]
    environment:
      - AWS_ACCESS_KEY_ID=test
      - AWS_SECRET_ACCESS_KEY=test
      - AWS_DEFAULT_REGION=us-east-1
      - AWS_ENDPOINT_URL=http://floci:4566
    volumes:
      - ./infrastructure/floci/init-aws.sh:/init-aws.sh:ro
    depends_on:
      floci:
        condition: service_healthy
    networks:
      - equalify-network

  # Docling-serve - PDF document conversion sidecar (CPU mode for dev)
  docling-serve:
    image: quay.io/docling-project/docling-serve-cpu:latest
    container_name: equalify-reflow-docling-serve
    restart: unless-stopped
    ports:
      - "5001:5001"
    environment:
      - DOCLING_SERVE_LOAD_MODELS_AT_BOOT=true
      - DOCLING_SERVE_ENG_LOC_SHARE_MODELS=true
      - DOCLING_SERVE_MAX_SYNC_WAIT=600
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:5001/health" ]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 120s
    deploy:
      resources:
        limits:
          memory: 8G
    networks:
      - equalify-network

  # Development overrides for API Gateway
  api-gateway:
    build:
      target: development # Use development stage for hot-reload
    ports:
      - "8080:8080" # API endpoints (includes /metrics)
    volumes:
      # Mount source code for hot-reload (read-only to prevent accidental writes)
      - ./src:/app/src:ro
      # Mount agent prompt configurations
      - ./config:/app/config:ro
      # Mount tests for containerized test runs
      - ./tests:/app/tests:ro
      # Mount pytest configuration
      - ./pytest.ini:/app/pytest.ini:ro
      - ./pyproject.toml:/app/pyproject.toml:ro
      - ./tailwind.config.js:/app/tailwind.config.js:ro
      # Mount Docker socket for testcontainers
      - /var/run/docker.sock:/var/run/docker.sock
      # Mount LTI RSA keys for Canvas integration
      - ./keys:/app/keys:ro
      # Mount built pipeline viewer (run `make build-viewer` to update)
      - ./clients/viewer/dist:/app/static/viewer:ro
    environment:
      # AWS Hybrid Configuration - Floci for S3/CloudWatch, Real AWS for Bedrock
      # Use service-specific endpoints (no global endpoint to avoid bedrock conflicts)
      - AWS_ENDPOINT_URL_S3=http://floci:4566
      - AWS_ENDPOINT_URL_CLOUDWATCH=http://floci:4566
      # AWS_ENDPOINT_URL_BEDROCK_RUNTIME not set โ†’ uses real AWS
      # Real AWS credentials from host environment (for Bedrock API access)
      # These override the Floci test credentials for services that need real AWS
      # Fallback to 'test' for Floci when real credentials aren't available
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-test}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-test}
      - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:-}
      # Clear AWS_PROFILE to prevent boto3 from looking for profile config in container
      - AWS_PROFILE=
      - AWS_DEFAULT_REGION=us-east-1
      # Disable AWS Instance Metadata Service (IMDS) to prevent boto3 hang in Docker
      - AWS_EC2_METADATA_DISABLED=true
      # S3 Configuration
      - S3_TEMP_BUCKET=equalify-pdf-temp
      - S3_RESULTS_BUCKET=equalify-pdf-results
      - S3_PUBLIC_URL=http://localhost:4566
      # Redis: use explicit container name to avoid DNS collision with Canvas Redis
      # when api-gateway is on both equalify-network and canvas-lms_default network
      - REDIS_URL=redis://equalify-reflow-redis:6379
      # Application
      - LOG_LEVEL=DEBUG
      - ENVIRONMENT=dev
      - ENABLE_METRICS=true
      # OpenTelemetry Configuration
      - TELEMETRY_ENABLED=true
      - TELEMETRY_OTLP_ENDPOINT=jaeger:4317
      - TELEMETRY_LOG_PROMPTS=true
      # Logfire Configuration (PydanticAI agent tracing)
      - LOGFIRE_ENABLED=${LOGFIRE_ENABLED:-false}
      - LOGFIRE_TOKEN=${LOGFIRE_TOKEN:-}
      # Docling-serve sidecar
      - DOCLING_SERVE_URL=http://docling-serve:5001
    command: [ "uv", "run", "uvicorn", "src.main:app", "--reload", "--host", "0.0.0.0", "--port", "8080", "--proxy-headers", "--forwarded-allow-ips", "*" ]
    networks:
      equalify-network:
        # Default network โ€” redis, floci hostnames resolve here
    depends_on:
      redis:
        condition: service_healthy
      floci-init:
        condition: service_completed_successfully
      docling-serve:
        condition: service_healthy

  # NOTE: Viewer is bundled into the API container
  # In development, run `make build-viewer` to rebuild the frontend
  # Then access it at http://localhost:8080/ (no auth โ€” publicly accessible)

  # Redis Exporter - Exposes Redis metrics to Prometheus
  redis-exporter:
    image: oliver006/redis_exporter:latest
    container_name: equalify-reflow-redis-exporter
    restart: unless-stopped
    ports:
      - "9121:9121"
    environment:
      - REDIS_ADDR=redis://redis:6379
    depends_on:
      redis:
        condition: service_healthy
    networks:
      - equalify-network

  # Prometheus - Metrics collection and storage
  prometheus:
    image: prom/prometheus:latest
    container_name: equalify-reflow-prometheus
    restart: unless-stopped
    ports:
      - "9090:9090"
    volumes:
      - ./infrastructure/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus-data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--storage.tsdb.retention.time=15d'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
      - '--web.enable-lifecycle'
    depends_on:
      api-gateway:
        condition: service_started
      redis-exporter:
        condition: service_started
    networks:
      - equalify-network
    healthcheck:
      test: [ "CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy" ]
      interval: 10s
      timeout: 5s
      retries: 3

  # Grafana - Metrics visualization and dashboards
  grafana:
    image: grafana/grafana:latest
    container_name: equalify-reflow-grafana
    restart: unless-stopped
    ports:
      - "3001:3000"
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
      - GF_USERS_ALLOW_SIGN_UP=false
      - GF_USERS_ALLOW_ORG_CREATE=false
      - GF_AUTH_ANONYMOUS_ENABLED=false
      - GF_SERVER_ROOT_URL=http://localhost:3001
      - GF_LOG_LEVEL=info
    volumes:
      - ./infrastructure/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
      - ./infrastructure/grafana/datasources:/etc/grafana/provisioning/datasources:ro
      - grafana-data:/var/lib/grafana
    depends_on:
      prometheus:
        condition: service_healthy
    networks:
      - equalify-network
    healthcheck:
      test: [ "CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health" ]
      interval: 10s
      timeout: 5s
      retries: 3

  # Jaeger - Distributed tracing UI for OpenTelemetry
  jaeger:
    image: jaegertracing/all-in-one:latest
    container_name: equalify-reflow-jaeger
    restart: unless-stopped
    ports:
      - "16686:16686"  # Jaeger UI
      - "4317:4317"    # OTLP gRPC receiver
      - "4318:4318"    # OTLP HTTP receiver
    environment:
      - COLLECTOR_OTLP_ENABLED=true
    networks:
      - equalify-network
    healthcheck:
      test: [ "CMD", "wget", "--spider", "-q", "http://localhost:16686/" ]
      interval: 10s
      timeout: 5s
      retries: 3

networks:
  equalify-network:
    external: false

volumes:
  floci-data:
    name: equalify-reflow-floci-data
  prometheus-data:
    name: equalify-reflow-prometheus-data
  grafana-data:
    name: equalify-reflow-grafana-data