version: '2'

volumes:
  sockets:
    external: true
  postgres_data:
    driver: local
  postgres_backup:
    driver: local

services:
  postgres:
    build: ./compose/postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - postgres_backup:/backups
    env_file: .env

  django:
    build:
      context: .
      dockerfile: ./compose/django/Dockerfile
    user: django
    depends_on:
      - postgres
      # - redis
    command: /stage-gunicorn-mhackspace.sh
    env_file: .env
    volumes:
      - .:/app
      - sockets:/data/sockets

  redis:
    image: redis:latest

  celeryworker:
    build:
      context: .
      dockerfile: ./compose/django/Dockerfile
    env_file: .env
    volumes:
      - .:/app
    depends_on:
      - postgres
      - redis
    command: celery -A mhackspace.celeryapp worker -l INFO

  celerybeat:
    build:
      context: .
      dockerfile: ./compose/django/Dockerfile
    env_file: .env
    volumes:
      - .:/app
    depends_on:
      - postgres
      - redis
    command: celery -A mhackspace.celeryapp beat -l INFO
