# IoT Agent JSON - Registry in Memory (no MongoDB needed)
# Usage: docker compose -f docker-compose.yml -f docker-compose.iot-agent.yml up -d

version: '3.8'

services:
  iot-agent:
    image: fiware/iotagent-json:latest
    container_name: smart-city-iot-agent
    restart: unless-stopped
    networks:
      - smartcity-shared
      - traefik-public
    ports:
      - "4041:4041"
    environment:
      # Context Broker (Stellio)
      - IOTA_CB_HOST=stellio-api-gateway
      - IOTA_CB_PORT=8080
      - IOTA_CB_NGSI_VERSION=ld
      # IoT Agent settings
      - IOTA_NORTH_PORT=4041
      - IOTA_REGISTRY_TYPE=memory
      # MQTT Listener - connect to EMQX
      - IOTA_MQTT_HOST=emqx_emqx_1
      - IOTA_MQTT_PORT=1883
      # No MongoDB needed - using memory registry
      - IOTA_PROVIDER_URL=http://smart-city-iot-agent:4041
      - IOTA_DEFAULT_RESOURCE=/
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:4041/version || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.iot-agent.rule=Host(`iot-agent.digitribe.fr`)"
      - "traefik.http.routers.iot-agent.entrypoints=websecure"
      - "traefik.http.routers.iot-agent.tls=true"
      - "traefik.http.services.iot-agent.loadbalancer.server.port=4041"

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