version: "3.5"

services:
  cassandra:
    image: cassandra:3.11
    networks:
      services-network:
        aliases:
          - cassandra

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - ./mysql-init:/docker-entrypoint-initdb.d
    networks:
      services-network:
        aliases:
          - mysql

  postgresql:
    image: postgres:9.6
    environment:
      POSTGRES_USER: temporal
      POSTGRES_PASSWORD: temporal
    volumes:
      - ./postgresql-init:/docker-entrypoint-initdb.d
    networks:
      services-network:
        aliases:
          - postgresql

  elasticsearch:
    image: elasticsearch:7.10.1
    networks:
      services-network:
        aliases:
          - elasticsearch
    environment:
      - discovery.type=single-node

  build:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "CASSANDRA_SEEDS=cassandra"
      - "MYSQL_SEEDS=mysql"
      - "POSTGRES_SEEDS=postgresql"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_BRANCH
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
      - FOSSA_API_KEY
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent

  unit-test:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "CASSANDRA_SEEDS=cassandra"
      - "MYSQL_SEEDS=mysql"
      - "POSTGRES_SEEDS=postgresql"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - cassandra
      - mysql
      - postgresql
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - unit-test

  integration-test-cassandra:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "CASSANDRA_SEEDS=cassandra"
      - "ES_SEEDS=elasticsearch"
      - "ES_VERSION=v7"
      - "PERSISTENCE_TYPE=nosql"
      - "PERSISTENCE_DRIVER=cassandra"
      - "TEST_TAG=esintegration"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - cassandra
      - elasticsearch
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test

  integration-test-mysql:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "MYSQL_SEEDS=mysql"
      - "ES_SEEDS=elasticsearch"
      - "ES_VERSION=v7"
      - "PERSISTENCE_TYPE=sql"
      - "PERSISTENCE_DRIVER=mysql"
      - "TEST_TAG=esintegration"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - mysql
      - elasticsearch
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test

  integration-test-postgresql:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "POSTGRES_SEEDS=postgresql"
      - "ES_SEEDS=elasticsearch"
      - "ES_VERSION=v7"
      - "PERSISTENCE_TYPE=sql"
      - "PERSISTENCE_DRIVER=postgres"
      - "TEST_TAG=esintegration"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - postgresql
      - elasticsearch
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test

  integration-test-xdc-cassandra:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "CASSANDRA_SEEDS=cassandra"
      - "ES_SEEDS=elasticsearch"
      - "ES_VERSION=v7"
      - "PERSISTENCE_TYPE=nosql"
      - "PERSISTENCE_DRIVER=cassandra"
      - "TEST_TAG=esintegration"
      - "TEST_RUN_COUNT=10"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - cassandra
      - elasticsearch
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test-xdc

  integration-test-xdc-mysql:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "MYSQL_SEEDS=mysql"
      - "ES_SEEDS=elasticsearch"
      - "ES_VERSION=v7"
      - "PERSISTENCE_TYPE=sql"
      - "PERSISTENCE_DRIVER=mysql"
      - "TEST_TAG=esintegration"
      - "TEST_RUN_COUNT=10"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - mysql
      - elasticsearch
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test-xdc

  integration-test-xdc-postgresql:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - "POSTGRES_SEEDS=postgresql"
      - "ES_SEEDS=elasticsearch"
      - "ES_VERSION=v7"
      - "PERSISTENCE_TYPE=sql"
      - "PERSISTENCE_DRIVER=postgres"
      - "TEST_TAG=esintegration"
      - "TEST_RUN_COUNT=10"
      - "TEMPORAL_VERSION_CHECK_DISABLED=1"
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
    depends_on:
      - postgresql
      - elasticsearch
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
    networks:
      services-network:
        aliases:
          - integration-test-xdc

  coverage-report:
    build:
      context: ../..
      dockerfile: ./develop/buildkite/Dockerfile
    environment:
      - CI
      - BUILDKITE
      - BUILDKITE_AGENT_ACCESS_TOKEN
      - BUILDKITE_JOB_ID
      - BUILDKITE_BUILD_ID
      - BUILDKITE_BUILD_NUMBER
      - BUILDKITE_BRANCH
      - BUILDKITE_BUILD_URL
      - BUILDKITE_PROJECT_SLUG
      - BUILDKITE_COMMIT
      - BUILDKITE_PULL_REQUEST
      - BUILDKITE_TAG
      - BUILDKITE_REPO
      - BUILDKITE_BUILD_CREATOR
      - BUILDKITE_BUILD_CREATOR_EMAIL
      - BUILDKITE_BUILD_CREATOR_TEAMS
      - BUILDKITE_PULL_REQUEST_REPO
      - COVERALLS_TOKEN
    volumes:
      - ../..:/temporal
      - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent

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