version: '3.5'
services:
  # PostgreSQL database
  db:
    build:
      context: ./_dockerfiles/db
      dockerfile: Dockerfile
    hostname: db
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
    ports:
      - "5436:5432"
    volumes:
      - gm-db:/var/lib/postgresql/data/
      - .:/code

  elasticsearch:
    image: elasticsearch:7.3.1
    volumes:
      - gm-esdata:/usr/share/elasticsearch/data
    hostname: elasticsearch
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
      - discovery.type=single-node
      - xpack.security.enabled=false

  # Redis
  redis:
    image: redis:latest

  # Celery
  worker:
    build: .
    command: ./run_celery.sh
    environment:
      - SETTINGS_CONFIGURATION=local
      - DB_NAME=postgres
      - DB_USERNAME=postgres
      - DB_HOSTNAME=db
      - DB_PORT=5432
      - DB_PASSWORD=postgres
    volumes:
      - .:/code
    links:
      - db
#      - rabbitmq
      - redis

  worker_beat:
    build: .
    command: ./run_celery_beat.sh
    environment:
      - SETTINGS_CONFIGURATION=local
      - DB_NAME=postgres
      - DB_USERNAME=postgres
      - DB_HOSTNAME=db
      - DB_PORT=5432
      - DB_PASSWORD=postgres
    volumes:
      - .:/code
    links:
      - db
#      - rabbitmq
      - redis
  # App: G&M
  gm_app:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    environment:
      - SETTINGS_CONFIGURATION=local
      - DB_HOSTNAME=db
      - DB_PORT=5432
      - DB_NAME=postgres
      - DB_USERNAME=postgres
      - DB_PASSWORD=postgres
    depends_on:
      - db
#      - rabbitmq
      - redis
      - worker
      - worker_beat
      - elasticsearch
    volumes:
      - .:/code
      - gm-media:/media-data
    ports:
      - "8000:8000"

volumes:
  gm-db:
    name: gm-db

  gm-media:
    name: gm-media

  gm-esdata: