version: '3.4'
name: weaviate
services:
{% set raft_join = [] -%}
{% for i in range(NUMBER_VOTERS|int) -%}
  {% do raft_join.append('weaviate-voter-' ~ i ~ ':830' ~ i) -%}
{% endfor -%}
{% set raft_join = raft_join | join(',') -%}
{% for i in range(NUMBER_VOTERS|int) %}
  weaviate-voter-{{ i }}:
    image: weaviate/test-server
    build:
      context: .
      dockerfile: Dockerfile
      target: weaviate
    restart: on-failure:0
    ports:
      - "808{{ i }}:8080"
      - "606{{ i }}:6060"
      - "5005{{ i+1 }}:50051"
    environment:
      LOG_LEVEL: "debug"
      CONTEXTIONARY_URL: contextionary:9999
      QUERY_DEFAULTS_LIMIT: 20
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: "./data"
      DEFAULT_VECTORIZER_MODULE: text2vec-contextionary
      ENABLE_MODULES: "text2vec-contextionary"
      PROMETHEUS_MONITORING_ENABLED: 'true'
      PROMETHEUS_MONITORING_GROUP_CLASSES: 'true'
      CLUSTER_HOSTNAME: "weaviate-voter-{{ i }}"
      CLUSTER_JOIN: weaviate-voter-0:7100
      CLUSTER_GOSSIP_BIND_PORT: "7100"
      CLUSTER_DATA_BIND_PORT: "7101"
      ASYNC_INDEXING: ${ASYNC_INDEXING:-false}
      RAFT_BOOTSTRAP_EXPECT: {{ NUMBER_VOTERS }}
      RAFT_JOIN: "{{ raft_join }}"
      # necessary for the metrics tests, some metrics only exist once segments
      # are flushed. If we wait to long the before run is completely in
      # memtables, the after run has some flushed which leads to some metrics
      # diffs in the before and after
      PERSISTENCE_MEMTABLES_FLUSH_IDLE_AFTER_SECONDS: 2
{% endfor %}
  weaviate:
    image: weaviate/test-server
    build:
      context: .
      dockerfile: Dockerfile
      target: weaviate
    restart: on-failure:0
    ports:
      - "8080"
      - "6060"
      - "50051"
    environment:
      LOG_LEVEL: "debug"
      CONTEXTIONARY_URL: contextionary:9999
      QUERY_DEFAULTS_LIMIT: 20
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: "./data"
      DEFAULT_VECTORIZER_MODULE: text2vec-contextionary
      ENABLE_MODULES: "text2vec-contextionary"
      PROMETHEUS_MONITORING_ENABLED: 'true'
      PROMETHEUS_MONITORING_GROUP_CLASSES: 'true'
      CLUSTER_GOSSIP_BIND_PORT: "7100"
      CLUSTER_DATA_BIND_PORT: "7101"
      CLUSTER_JOIN: weaviate-voter-0:7100
      ASYNC_INDEXING: ${ASYNC_INDEXING:-false}
      RAFT_BOOTSTRAP_EXPECT: {{ NUMBER_VOTERS }}
      RAFT_JOIN: "{{ raft_join }}"
      # necessary for the metrics tests, some metrics only exist once segments
      # are flushed. If we wait to long the before run is completely in
      # memtables, the after run has some flushed which leads to some metrics
      # diffs in the before and after
      PERSISTENCE_MEMTABLES_FLUSH_IDLE_AFTER_SECONDS: 2
    depends_on:
      - weaviate-voter-{{ NUMBER_VOTERS|int - 1}}
  contextionary:
    image: semitechnologies/contextionary:en0.16.0-v1.2.1
    ports:
      - "9999:9999"
    environment:
      OCCURRENCE_WEIGHT_LINEAR_FACTOR: 0.75
      EXTENSIONS_STORAGE_MODE: weaviate
      EXTENSIONS_STORAGE_ORIGIN: http://weaviate-voter-0:8080