version: '3.8'

services:
  # TypeScript SDK server for testing Rust clients
  typescript-server:
    image: node:20-alpine
    working_dir: /app
    volumes:
      - .:/app
      - ./node_modules:/app/node_modules
    command: |
      sh -c "
        npm install &&
        node test-server.js
      "
    networks:
      - mcp-test
    ports:
      - "8080:8080"
    healthcheck:
      test: ["CMD", "node", "-e", "process.exit(0)"]
      interval: 5s
      timeout: 3s
      retries: 5

  # Rust SDK server for testing TypeScript clients
  rust-server:
    build:
      context: ../../..
      dockerfile: tests/integration/typescript-interop/Dockerfile.rust
    working_dir: /app
    command: cargo run --example 02_server_basic
    networks:
      - mcp-test
    ports:
      - "8081:8081"
    healthcheck:
      test: ["CMD", "cargo", "--version"]
      interval: 5s
      timeout: 3s
      retries: 5

  # Test runner that executes all integration tests
  test-runner:
    build:
      context: ../../..
      dockerfile: tests/integration/typescript-interop/Dockerfile.test
    working_dir: /app
    depends_on:
      typescript-server:
        condition: service_healthy
      rust-server:
        condition: service_healthy
    command: |
      sh -c "
        echo 'Running integration tests...' &&
        cargo test --test typescript_interop &&
        cd tests/integration/typescript-interop &&
        npm test
      "
    networks:
      - mcp-test
    environment:
      - RUST_LOG=debug
      - NODE_ENV=test

networks:
  mcp-test:
    driver: bridge