215 lines
5.6 KiB
YAML
215 lines
5.6 KiB
YAML
# Docker Compose configuration for COBY Multi-Exchange Data Aggregation System
|
|
version: '3.8'
|
|
|
|
services:
|
|
# TimescaleDB Database
|
|
timescaledb:
|
|
image: timescale/timescaledb:latest-pg15
|
|
container_name: coby-timescaledb
|
|
environment:
|
|
POSTGRES_DB: ${DB_NAME:-market_data}
|
|
POSTGRES_USER: ${DB_USER:-market_user}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD:-market_data_secure_pass_2024}
|
|
TIMESCALEDB_TELEMETRY: 'off'
|
|
ports:
|
|
- "${DB_PORT:-5432}:5432"
|
|
volumes:
|
|
- timescale_data:/var/lib/postgresql/data
|
|
- ./docker/init-scripts:/docker-entrypoint-initdb.d
|
|
networks:
|
|
- coby-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-market_user} -d ${DB_NAME:-market_data}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# Redis Cache
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: coby-redis
|
|
command: redis-server /usr/local/etc/redis/redis.conf
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
- ./docker/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
|
networks:
|
|
- coby-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 3
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# COBY Main Application
|
|
coby-app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
target: production
|
|
container_name: coby-app
|
|
environment:
|
|
# Database configuration
|
|
DB_HOST: timescaledb
|
|
DB_PORT: 5432
|
|
DB_NAME: ${DB_NAME:-market_data}
|
|
DB_USER: ${DB_USER:-market_user}
|
|
DB_PASSWORD: ${DB_PASSWORD:-market_data_secure_pass_2024}
|
|
|
|
# Redis configuration
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
REDIS_PASSWORD: ${REDIS_PASSWORD:-market_data_redis_2024}
|
|
|
|
# Application configuration
|
|
ENVIRONMENT: ${ENVIRONMENT:-production}
|
|
DEBUG: ${DEBUG:-false}
|
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
|
|
|
# API configuration
|
|
API_HOST: 0.0.0.0
|
|
API_PORT: 8080
|
|
WS_PORT: 8081
|
|
|
|
# Performance configuration
|
|
MAX_CONNECTIONS_PER_EXCHANGE: ${MAX_CONNECTIONS_PER_EXCHANGE:-5}
|
|
DATA_BUFFER_SIZE: ${DATA_BUFFER_SIZE:-10000}
|
|
BATCH_WRITE_SIZE: ${BATCH_WRITE_SIZE:-1000}
|
|
|
|
# Monitoring configuration
|
|
BUCKET_SIZE: ${BUCKET_SIZE:-1.0}
|
|
HEATMAP_DEPTH: ${HEATMAP_DEPTH:-50}
|
|
UPDATE_FREQUENCY: ${UPDATE_FREQUENCY:-0.5}
|
|
ports:
|
|
- "${API_PORT:-8080}:8080"
|
|
- "${WS_PORT:-8081}:8081"
|
|
volumes:
|
|
- ./logs:/app/logs
|
|
- ./data:/app/data
|
|
networks:
|
|
- coby-network
|
|
depends_on:
|
|
timescaledb:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8080/health', timeout=5)"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "50m"
|
|
max-file: "5"
|
|
|
|
# Web Dashboard (Nginx serving static files)
|
|
coby-dashboard:
|
|
image: nginx:alpine
|
|
container_name: coby-dashboard
|
|
ports:
|
|
- "${DASHBOARD_PORT:-3000}:80"
|
|
volumes:
|
|
- ./web/static:/usr/share/nginx/html:ro
|
|
- ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
networks:
|
|
- coby-network
|
|
depends_on:
|
|
- coby-app
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# Prometheus (Optional - for monitoring)
|
|
prometheus:
|
|
image: prom/prometheus:latest
|
|
container_name: coby-prometheus
|
|
ports:
|
|
- "${PROMETHEUS_PORT:-9090}:9090"
|
|
volumes:
|
|
- ./docker/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
- prometheus_data:/prometheus
|
|
networks:
|
|
- coby-network
|
|
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=200h'
|
|
- '--web.enable-lifecycle'
|
|
restart: unless-stopped
|
|
profiles:
|
|
- monitoring
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# Grafana (Optional - for visualization)
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
container_name: coby-grafana
|
|
ports:
|
|
- "${GRAFANA_PORT:-3001}:3000"
|
|
environment:
|
|
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin}
|
|
GF_USERS_ALLOW_SIGN_UP: false
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./docker/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
|
|
- ./docker/grafana/datasources:/etc/grafana/provisioning/datasources:ro
|
|
networks:
|
|
- coby-network
|
|
depends_on:
|
|
- prometheus
|
|
restart: unless-stopped
|
|
profiles:
|
|
- monitoring
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
networks:
|
|
coby-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.20.0.0/16
|
|
|
|
volumes:
|
|
timescale_data:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
prometheus_data:
|
|
driver: local
|
|
grafana_data:
|
|
driver: local |