version: "3.5"

services:
  cassandra:
    image: cassandra:4.1.1
    environment:
      - "MAX_HEAP_SIZE=256M"
      - "HEAP_NEWSIZE=128M"
    networks:
      services-network:
        aliases:
          - cassandra
    healthcheck:
      test: ["CMD", "cqlsh", "-u cassandra", "-p cassandra" ,"-e describe keyspaces"]
      interval: 15s
      timeout: 30s
      retries: 10

  zookeeper:
    image: wurstmeister/zookeeper:3.4.6
    networks:
      services-network:
        aliases:
          - zookeeper

  kafka:
    image: wurstmeister/kafka:2.12-2.1.1
    depends_on:
      - zookeeper
    networks:
      services-network:
        aliases:
          - kafka
    environment:
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

  elasticsearch:
    image: opensearchproject/opensearch:2.5.0
    networks:
      services-network:
        aliases:
          - elasticsearch
    environment:
      - discovery.type=single-node
      - "DISABLE_SECURITY_PLUGIN=true"

  integration-test-cassandra:
    build:
      context: ../../
      dockerfile: ./docker/buildkite/Dockerfile
    environment:
      - "CASSANDRA=1"
      - "CASSANDRA_SEEDS=cassandra"
      - "ES_SEEDS=elasticsearch"
      - "KAFKA_SEEDS=kafka"
      - "TEST_TAG=esintegration"
      - "ES_VERSION=os2"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      cassandra:
        condition: service_healthy
      elasticsearch:
        condition: service_started
      kafka:
        condition: service_started
    volumes:
      - ../../:/cadence
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test

networks:
  services-network:
    name: services-network
    driver: bridge
