# Docker Compose for interactive chat testing.
# Usage: ./scripts/chat-test.sh  (wraps this file with tmux orchestration)

networks:
  chatnet:
    driver: bridge

volumes:
  server-data:

services:
  server:
    build:
      context: ..
      dockerfile: docker/Dockerfile.chat-test
    command: >-
      qpc-server
        --listen 0.0.0.0:7000
        --data-dir /data
        --tls-cert /data/server-cert.der
        --tls-key /data/server-key.der
        --auth-token devtoken
        --allow-insecure-auth
    environment:
      RUST_LOG: info
    volumes:
      - server-data:/data
    networks:
      - chatnet
    healthcheck:
      test: ["CMD", "bash", "-c", "echo '' > /dev/tcp/localhost/7000"]
      interval: 3s
      timeout: 2s
      retries: 20
      start_period: 5s

  alice:
    build:
      context: ..
      dockerfile: docker/Dockerfile.chat-test
    stdin_open: true
    tty: true
    entrypoint: ["sleep", "infinity"]
    environment:
      RUST_LOG: warn
      QPC_ACCESS_TOKEN: devtoken
      QPC_CA_CERT: /data/server-cert.der
      QPC_SERVER_NAME: localhost
      QPC_SERVER: "server:7000"
    volumes:
      - server-data:/data:ro
    working_dir: /chat
    networks:
      - chatnet
    depends_on:
      server:
        condition: service_healthy

  bob:
    build:
      context: ..
      dockerfile: docker/Dockerfile.chat-test
    stdin_open: true
    tty: true
    entrypoint: ["sleep", "infinity"]
    environment:
      RUST_LOG: warn
      QPC_ACCESS_TOKEN: devtoken
      QPC_CA_CERT: /data/server-cert.der
      QPC_SERVER_NAME: localhost
      QPC_SERVER: "server:7000"
    volumes:
      - server-data:/data:ro
    working_dir: /chat
    networks:
      - chatnet
    depends_on:
      server:
        condition: service_healthy
