Aller au contenu principal

Topologie Docker Compose

Fonrex s'appuie sur Docker Compose pour orchestrer son architecture multi-services. L'architecture isole la logique backend, la base de données, le cache et les migrations.

Architecture des Conteneurs

┌───────────────────────────────────────────────────────────┐
│ docker-compose │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ fonrex-api │ │ fonrex-db │ │fonrex-redis │ │
│ │ (FastAPI:5000) │ │ (TimescaleDB) │ │ (Redis:7) │ │
│ └────────┬────────┘ └────────┬────────┘ └──────┬──────┘ │
│ │ │ │ │
│ └───────────────────┴─────────────────┘ │
│ │ │
│ ┌────────┴────────┐ │
│ │ fonrex-migrate │ │
│ │ (Alembic CLI) │ │
│ └─────────────────┘ │
└───────────────────────────────────────────────────────────┘

Détail des Services

1. fonrex-api

  • Container Image: Custom Python 3.12 (Dockerfile)
  • Port Exposure: 5000:5000
  • Command: gunicorn -k uvicorn.workers.UvicornWorker main:app
  • Role: Serves REST endpoints, WebSocket connections, background ingestion tasks, provider monitoring, and DCF calculations.

2. fonrex-db

  • Container Image: timescale/timescaledb-ha:pg16
  • Port Exposure: 5432:5432
  • Volume Mount: postgres_data:/var/lib/postgresql/data
  • Role: Primary database holding canonical assets, listings, historical EOD prices, intraday hypertables, fundamentals, news, and health logs.

3. fonrex-redis

  • Container Image: redis:7-alpine
  • Port Exposure: 6379:6379
  • Command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
  • Role: High-speed cache for quotes, indicator computations, news feeds, DCF metrics, and WebSocket Pub/Sub broker.

4. fonrex-migrate

  • Container Image: Custom Python 3.12 (Dockerfile)
  • Profiles: ["migrate"]
  • Command: alembic upgrade head
  • Role: Isolated one-shot container executing schema migrations safely before application startup.

Opérations Courantes

Start Stack

docker compose up -d

View Live API Logs

docker compose logs -f fonrex-api

Run Database Migrations Manuellely

docker compose --profile migrate run --rm fonrex-migrate

Stop & Remove Containers (Preserving Data)

docker compose down

Reset All Data Volumes (Destructive)

docker compose down -v