version: '3'

services:
  # postgres
  pg:
    image: postgres:alpine
    environment:
      POSTGRES_USER: iri
      POSTGRES_PASSWORD: iri
      POSTGRES_DB: hdalab
    ports:
      - '5432:5432'
    volumes:
      - pg-data:/var/lib/postgresql/data
  # nginx (webserver)
  front:
    build:
      context: ./front
    ports:
      - '8080:80'
    depends_on:
      - "hdalab"
    volumes:
      - static-content:/var/lib/hdalab/static
      - front-data:/usr/share/nginx/html
      - front-logs:/var/log/nginx
  # Elasticsearch
  es:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.8
    environment:
      - "discovery.type=single-node"
      - "cluster.name=docker-cluster"
      - "xpack.security.enabled=false"
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    volumes:
      - es-data:/usr/share/elasticsearch/data
  # mailhog
  mail:
    image: mailhog/mailhog
    ports:
      - "8025:8025"
  # rabbitmq
  rabbitmq:
    hostname: hdalab-rabbitmq
    image: rabbitmq:alpine
    environment:
      RABBITMQ_DEFAULT_VHOST: hdalab

  # hdalab
  hdalab:
    build: ./hdalab
    volumes:
      - static-content:/var/lib/hdalab/static
      - hdalab-logs:/var/log/hdalab
    depends_on:
      - "pg"
      - "es"
      - "mail"
      - "rabbitmq"

volumes:
  static-content:
  hdalab-logs:
  pg-data:
  front-data:
  front-logs:
  es-data:

