Skip to main content

Federation Service Deployment

Docker Deployment

Build Image

cd shared/federation
docker build -t federation:latest .

Run Container

docker run -d \
--name federation \
-p 8020:8020 \
-e DATABASE_URL=postgresql+asyncpg://user:pass@postgres:5432/federation \
-e REDIS_URL=redis://redis:6379 \
federation:latest

Docker Compose

The service is included in infra/compose.yml:

federation:
build: ./shared/federation
ports:
- "8020:8020"
environment:
- DATABASE_URL=postgresql+asyncpg://user:pass@postgres:5432/federation
- REDIS_URL=redis://redis:6379
depends_on:
- postgres
- redis

Production Deployment

Prerequisites

  • PostgreSQL 14+ database
  • Redis instance
  • Python 3.11+

Steps

  1. Install Dependencies:
cd shared/federation
uv pip install -e .
  1. Run Migrations:
alembic upgrade head
  1. Start Service:
uvicorn app.main:app --host 0.0.0.0 --port 8020

Production Server

For production, use a production ASGI server:

gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8020

Health Checks

  • GET /health - Basic health check
  • GET /health/detailed - Detailed health including database and services

Monitoring

Metrics

Prometheus metrics available at /metrics.

Tracing

OpenTelemetry tracing configured for distributed tracing.

Scaling

The service can be horizontally scaled. Ensure all instances:

  • Connect to the same PostgreSQL database
  • Use the same Redis instance for service discovery
  • Share schema cache via PostgreSQL