version: '3'

volumes:
  local_postgres_data: {}
  local_postgres_data_backups: {}

services:
  django: &django
    build:
      context: .
      dockerfile: ./compose/local/django/Dockerfile
    image: sayches_local_django
    stdin_open: true
    tty: true
    depends_on:
      - postgres
    volumes:
      - .:/app
    env_file:
      - ./.envs/.local
    ports:
      - "8000:8000"
    command: /start

  postgres:
    build:
      context: .
      dockerfile: ./compose/local/postgres/Dockerfile
    image: sayches_local_postgres
    volumes:
      - local_postgres_data:/var/lib/postgresql/data
      - local_postgres_data_backups:/backups
    env_file:
      - ./.envs/.local

  redis:
    container_name: sayches-redis
    image: redis

  celeryworker:
    <<: *django
    image: sayches_local_celeryworker
    depends_on:
      - redis
      - postgres
    ports: []
    command: /start-celeryworker

  celerybeat:
    <<: *django
    image: sayches_local_celerybeat
    depends_on:
      - redis
      - postgres
    ports: []
    command: /start-celerybeat

  flower:
    <<: *django
    image: sayches_local_flower
    ports:
      - "5545:5545"
    command: /start-flower