services:
  iroh-benchmark-direct-server:
    build:
      context: ../..
      dockerfile: server/Dockerfile
    entrypoint: ["node", "--import", "tsx", "e2e/iroh-network-benchmark-server.ts"]
    environment:
      BENCH_SERVER_LANE: direct
      OPPI_DATA_DIR: /data/oppi
      PI_CODING_AGENT_DIR: /data/pi-agent
      PI_AGENT_SYNC_MODE: skip
      OPPI_IROH_TRANSPORT: "1"
      OPPI_IROH_INVITE_MODE: irohPreferred
      OPPI_BONJOUR: "0"
      OPPI_LOG_LEVEL: warn
    volumes:
      - iroh-benchmark-direct-exchange:/exchange
      - iroh-benchmark-direct-data:/data/oppi
      - iroh-benchmark-direct-agent:/data/pi-agent
      - iroh-benchmark-direct-workspace:/workspace
    networks:
      - direct-bridge
    healthcheck:
      test: ["CMD-SHELL", "test -s /exchange/invite.json"]
      interval: 1s
      timeout: 2s
      retries: 90
      start_period: 5s

  iroh-benchmark-direct-client:
    build:
      context: ../..
      dockerfile: server/Dockerfile
    entrypoint: ["node", "--import", "tsx", "e2e/iroh-network-benchmark-client.ts"]
    environment:
      BENCH_CLIENT_LANE: direct
      BENCH_OUTPUT_PATH: /output/direct.json
    depends_on:
      iroh-benchmark-direct-server:
        condition: service_healthy
    volumes:
      - iroh-benchmark-direct-exchange:/exchange:ro
      - iroh-benchmark-direct-output:/output
    networks:
      - direct-bridge

  iroh-benchmark-relay-server:
    build:
      context: ../..
      dockerfile: server/Dockerfile
    cap_add:
      - NET_ADMIN
    entrypoint: ["node", "--import", "tsx", "e2e/iroh-network-benchmark-server.ts"]
    environment:
      BENCH_SERVER_LANE: relay
      OPPI_DATA_DIR: /data/oppi
      PI_CODING_AGENT_DIR: /data/pi-agent
      PI_AGENT_SYNC_MODE: skip
      OPPI_IROH_TRANSPORT: "1"
      OPPI_IROH_INVITE_MODE: irohOnly
      OPPI_BONJOUR: "0"
      OPPI_LOG_LEVEL: warn
    volumes:
      - iroh-benchmark-relay-exchange:/exchange
      - iroh-benchmark-relay-data:/data/oppi
      - iroh-benchmark-relay-agent:/data/pi-agent
      - iroh-benchmark-relay-workspace:/workspace
    networks:
      - relay-server-egress
    healthcheck:
      test: ["CMD-SHELL", "test -s /exchange/invite.json"]
      interval: 1s
      timeout: 2s
      retries: 90
      start_period: 5s

  iroh-benchmark-relay-client:
    build:
      context: ../..
      dockerfile: server/Dockerfile
    cap_add:
      - NET_ADMIN
    entrypoint: ["node", "--import", "tsx", "e2e/iroh-network-benchmark-client.ts"]
    environment:
      BENCH_CLIENT_LANE: relay
      BENCH_OUTPUT_PATH: /output/relay.json
    depends_on:
      iroh-benchmark-relay-server:
        condition: service_healthy
    volumes:
      - iroh-benchmark-relay-exchange:/exchange:ro
      - iroh-benchmark-relay-output:/output
    networks:
      - relay-client-egress

networks:
  direct-bridge:
  relay-server-egress:
  relay-client-egress:

volumes:
  iroh-benchmark-direct-exchange:
  iroh-benchmark-direct-data:
  iroh-benchmark-direct-agent:
  iroh-benchmark-direct-workspace:
  iroh-benchmark-direct-output:
  iroh-benchmark-relay-exchange:
  iroh-benchmark-relay-data:
  iroh-benchmark-relay-agent:
  iroh-benchmark-relay-workspace:
  iroh-benchmark-relay-output:
