# Redpanda (Kafka-compatible) — Single Node for Smart City Digital Twin Martinique
# Usage: docker compose -p smart-city -f redpanda/docker-compose.yml up -d
# Ports: 19092=Kafka (host), 9644=Admin API, 18083=Schema Registry
services:
  redpanda:
    image: redpandadata/redpanda:v24.3.14
    container_name: smart-city-redpanda
    command:
      - redpanda
      - start
      - --overprovisioned
      - --smp
      - "1"
      - --memory
      - 1G
      - --reserve-memory
      - 0M
      - --node-id
      - "0"
      - --check=false
      - --kafka-addr
      - internal://0.0.0.0:9092
      - --advertise-kafka-addr
      - internal://smart-city-redpanda:9092
      - --rpc-addr
      - internal://0.0.0.0:33145
      - --advertise-rpc-addr
      - smart-city-redpanda:33145
    ports:
      - "19092:9092"
      - "19644:9644"
      - "127.0.0.1:8082:8082" # REST Proxy for simulator
    volumes:
      - redpanda-data:/var/lib/redpanda/data
    networks:
      - traefik-public
      - smartcity-shared
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:9644/v1/status/ready 2>/dev/null || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 10
      start_period: 60s
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.redpanda.rule=Host(`redpanda.digitribe.fr`)"
      - "traefik.http.routers.redpanda.entrypoints=websecure"
      - "traefik.http.routers.redpanda.tls=true"
      - "traefik.http.services.redpanda.loadbalancer.server.port=9644"

  # Redpanda Console - Web UI for Redpanda/Kafka
  redpanda-console:
    image: docker.redpanda.com/redpandadata/console:v2.5.0
    container_name: smart-city-redpanda-console
    restart: unless-stopped
    depends_on:
      - redpanda
    environment:
      - KAFKA_BROKERS=smart-city-redpanda:9092
      - CONFIG_FILE=console.yaml
    volumes:
      - ./console.yaml:/console.yaml:ro
    networks:
      - traefik-public
      - smartcity-shared
    ports:
      - "28080:8080"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.redpanda-console.rule=Host(`redpanda-console.digitribe.fr`)"
      - "traefik.http.routers.redpanda-console.entrypoints=websecure"
      - "traefik.http.routers.redpanda-console.tls=true"
      - "traefik.http.services.redpanda-console.loadbalancer.server.port=8080"
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:8080 || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 30s

networks:
  traefik-public:
    external: true
  smartcity-shared:
    external: true

volumes:
  redpanda-data:
