File size: 9,178 Bytes
c293f7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Production Docker Compose configuration
# Optimized for production deployment with security and performance

# Production Docker Compose configuration
# Optimized for production deployment with security and performance

services:
  # ============================================================================
  # Production Application Service
  # ============================================================================
  app:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    image: misinformation-heatmap:${VERSION:-latest}
    container_name: misinformation-heatmap-prod
    ports:
      - "8080:8080"
    environment:
      # Production Configuration
      - MODE=cloud
      - ENVIRONMENT=production
      - LOG_LEVEL=INFO
      - API_HOST=0.0.0.0
      - API_PORT=8080
      
      # Security
      - API_KEY_ENABLED=true
      - API_KEYS=${API_KEYS:-}
      - CORS_ORIGINS=${CORS_ORIGINS:-["*"]}
      
      # Google Cloud Production (optional)
      - GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT:-}
      - GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS:-}
      - BIGQUERY_DATASET=${BIGQUERY_DATASET:-misinformation_heatmap}
      - BIGQUERY_LOCATION=${BIGQUERY_LOCATION:-US}
      
      # Pub/Sub Production
      - PUBSUB_EVENTS_RAW_TOPIC=${PUBSUB_EVENTS_RAW_TOPIC:-events-raw}
      - PUBSUB_EVENTS_PROCESSED_TOPIC=${PUBSUB_EVENTS_PROCESSED_TOPIC:-events-processed}
      - PUBSUB_EVENTS_VALIDATED_TOPIC=${PUBSUB_EVENTS_VALIDATED_TOPIC:-events-validated}
      
      # External Services (optional)
      - HUGGINGFACE_TOKEN=${HUGGINGFACE_TOKEN:-}
      - WATSON_DISCOVERY_API_KEY=${WATSON_DISCOVERY_API_KEY:-}
      
      # Performance & Caching
      - CACHE_TYPE=redis
      - CACHE_TTL=300
      - REDIS_URL=redis://redis:6379/0
      - RATE_LIMIT_ENABLED=true
      - RATE_LIMIT_REQUESTS_PER_MINUTE=100
      
      # Monitoring
      - ENABLE_METRICS=true
      - ENABLE_TRACING=true
      - TRACING_SAMPLE_RATE=0.1
      
      # Data Sources
      - DATA_SOURCES_CONFIG_PATH=/app/config/data_sources.yaml
      
    volumes:
      # Production data persistence
      - app-data:/app/data
      - app-logs:/app/logs
      - app-cache:/app/cache
      
      # Google Cloud credentials (uncomment if using service account file)
      # - ${GOOGLE_APPLICATION_CREDENTIALS_FILE:-./credentials.json}:/app/credentials.json:ro
      
      # Configuration (read-only)
      - ${PWD}/config:/app/config:ro
      
    depends_on:
      - redis
    networks:
      - misinformation-prod-network
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 4G
        reservations:
          cpus: '1.0'
          memory: 2G
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "5"

  # ============================================================================
  # Production Nginx Reverse Proxy
  # ============================================================================
  nginx:
    image: nginx:alpine
    container_name: misinformation-heatmap-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      # Nginx configuration
      - ${PWD}/docker/nginx-prod.conf:/etc/nginx/nginx.conf:ro
      - ${PWD}/docker/nginx/conf.d:/etc/nginx/conf.d:ro
      
      # SSL certificates (uncomment for HTTPS)
      # - ${SSL_CERT_PATH:-./ssl/cert.pem}:/etc/nginx/ssl/cert.pem:ro
      # - ${SSL_KEY_PATH:-./ssl/key.pem}:/etc/nginx/ssl/key.pem:ro
      
      # Static files
      - ${PWD}/frontend:/usr/share/nginx/html:ro
      
      # Logs
      - nginx-logs:/var/log/nginx
      
    depends_on:
      - app
    networks:
      - misinformation-prod-network
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
        reservations:
          cpus: '0.1'
          memory: 128M
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
      interval: 30s
      timeout: 5s
      retries: 3
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"

  # ============================================================================
  # Production Redis Cache
  # ============================================================================
  redis:
    image: redis:7-alpine
    container_name: misinformation-heatmap-redis-prod
    command: >
      redis-server 
      --appendonly yes 
      --maxmemory 1gb 
      --maxmemory-policy allkeys-lru
      --save 900 1
      --save 300 10
      --save 60 10000
    volumes:
      - redis-prod-data:/data
      - ${PWD}/docker/redis.conf:/usr/local/etc/redis/redis.conf:ro
    networks:
      - misinformation-prod-network
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1.5G
        reservations:
          cpus: '0.2'
          memory: 512M
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 30s
      timeout: 5s
      retries: 3
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"

  # ============================================================================
  # Production Monitoring Stack
  # ============================================================================
  prometheus:
    image: prom/prometheus:latest
    container_name: misinformation-heatmap-prometheus-prod
    ports:
      - "9090:9090"
    volumes:
      - ${PWD}/docker/prometheus-prod.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus-prod-data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--storage.tsdb.retention.time=30d'
      - '--web.enable-lifecycle'
      - '--web.enable-admin-api'
    networks:
      - misinformation-prod-network
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 2G
        reservations:
          cpus: '0.2'
          memory: 512M
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"

  grafana:
    image: grafana/grafana:latest
    container_name: misinformation-heatmap-grafana-prod
    ports:
      - "3001:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
      - GF_USERS_ALLOW_SIGN_UP=false
      - GF_SECURITY_ALLOW_EMBEDDING=true
      - GF_AUTH_ANONYMOUS_ENABLED=false
      - GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-worldmap-panel
    volumes:
      - grafana-prod-data:/var/lib/grafana
      - ${PWD}/docker/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
      - ${PWD}/docker/grafana/datasources:/etc/grafana/provisioning/datasources:ro
    networks:
      - misinformation-prod-network
    restart: unless-stopped
    depends_on:
      - prometheus
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 1G
        reservations:
          cpus: '0.1'
          memory: 256M
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"

  # ============================================================================
  # Log Aggregation (Optional)
  # ============================================================================
  fluentd:
    image: fluent/fluentd:v1.16-debian-1
    container_name: misinformation-heatmap-fluentd
    volumes:
      - ${PWD}/docker/fluentd.conf:/fluentd/etc/fluent.conf:ro
      - app-logs:/app/logs:ro
      - nginx-logs:/nginx/logs:ro
    networks:
      - misinformation-prod-network
    restart: unless-stopped
    profiles:
      - logging
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
        reservations:
          cpus: '0.1'
          memory: 128M

# ============================================================================
# Production Networks
# ============================================================================
networks:
  misinformation-prod-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.21.0.0/16
    driver_opts:
      com.docker.network.bridge.name: misinformation-prod

# ============================================================================
# Production Volumes
# ============================================================================
volumes:
  app-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: ${DATA_PATH:-./data}
  app-logs:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: ${LOGS_PATH:-./logs}
  app-cache:
    driver: local
  redis-prod-data:
    driver: local
  prometheus-prod-data:
    driver: local
  grafana-prod-data:
    driver: local
  nginx-logs:
    driver: local