version: "3.9"

services:
  tinybroker:
    image: phughk/tinybroker:latest
    restart: unless-stopped
    ports:
      - "50051:50051"   # gRPC API
      - "8080:8080"     # health checks  (GET /health, GET /ready)
      - "9090:9090"     # Prometheus metrics (GET /metrics)
    environment:
      RUST_LOG: info
    configs:
      - source: broker_config
        target: /config.json5
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:8080/ready"]
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 5s

configs:
  broker_config:
    content: |
      {
        bind: {
          grpc:    "[::]:50051",
          health:  "[::]:8080",
          metrics: "[::]:9090",
        },
        channel: {
          command_capacity:  256,
          consumer_capacity: 256,
          event_capacity:     64,
        },
        log: { format: "json" },
      }
