version: "3"

services:
  {% if database == "elasticsearch" -%}
  es:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    container_name: es
    command: ["bin/elasticsearch", "-Ediscovery.type=single-node"]
    ports:
      - 9200:9200
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx512m"

  kibana:
    image: docker.elastic.co/kibana/kibana:7.10.2
    environment:
      ELASTICSEARCH_HOSTS: http://es:9200
    ports:
      - 5601:5601
  {% elif database == "postgresql" -%}

  db:
    image: postgres:12.3-alpine
    restart: unless-stopped
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
    volumes:
      - db-data:/var/lib/postgresql/data
    command: ["postgres", "-c", "log_destination=stderr"]
  {% endif -%}
  {% if broker in ["redis", "celery"] or cache == "redis" -%}

  redis:
    image: redis:latest
    restart: unless-stopped
    ports:
      - 6379:6379
  {% endif -%}

  message-db:
    image: ethangarofolo/message-db:1.2.6
    ports:
      - 5433:5432

volumes:
  db-data:
    driver: local
