name: citusio-hello-world

services:
  iotd:
    image: ${CITUSIO_IMAGE:?Set the exact preloaded image reference}
    pull_policy: never
    user: iot
    command: ["iotd"]
    ipc: shareable
    shm_size: "512m"
    init: true
    # The gateway joins this network namespace. nginx owns these listeners.
    ports:
      - "127.0.0.1:1883:1883"
      - "127.0.0.1:8080:8080"
    environment:
      IOTD_CONFIG: /opt/nginz-iot/hello-world/iotd.toml
    healthcheck:
      test: ["CMD-SHELL", "ngz-iot --admin-file /run/nginz-iot/iotd/admin.json readiness | grep -q '^route_to_node=true$'"]
      interval: 2s
      timeout: 3s
      retries: 20
      start_period: 3s
    volumes:
      - .:/opt/nginz-iot/hello-world:ro
      - iotd-data:/var/lib/nginz-iot/iotd
      - runtime:/run/nginz-iot

  gateway:
    image: ${CITUSIO_IMAGE:?Set the exact preloaded image reference}
    pull_policy: never
    user: iot
    command: ["gateway"]
    depends_on:
      iotd:
        condition: service_healthy
    ipc: "service:iotd"
    # MPSC dead-producer recovery compares PID/start identity across roles.
    pid: "service:iotd"
    network_mode: "service:iotd"
    init: true
    volumes:
      - runtime:/run/nginz-iot

  bridge:
    image: ${CITUSIO_IMAGE:?Set the exact preloaded image reference}
    pull_policy: never
    user: iot
    command: ["bridge"]
    depends_on:
      iotd:
        condition: service_healthy
    ipc: "service:iotd"
    # Bridge recovery must resolve producer identity in iotd's PID namespace.
    pid: "service:iotd"
    network_mode: "service:iotd"
    init: true
    environment:
      BRIDGE_MANIFEST: /opt/nginz-iot/hello-world/bridges.toml
      NGINZ_IOT_HELLO_WORLD_SECRET: unused-by-file-example
    volumes:
      - .:/opt/nginz-iot/hello-world:ro
      - runtime:/run/nginz-iot

volumes:
  iotd-data:
  runtime:
