volumes:
  local_postgres_data: {}
  local_postgres_data_backups: {}

services:
  django: &django
    build:
      context: .
      dockerfile: ./compose/local/django/Dockerfile
      args:
        PYTHON_VERSION: 3.13
    image: django_structlog_demo_project_local_django
    depends_on:
      - postgres
    volumes:
      - .:/app:cached
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.redis
      - ./.envs/.local/.postgres
    tty: true # needed for colors to show in console logs
    ports:
      - "8000:8000"
    command: /start

  django_wsgi:
    <<: *django
    environment:
      DJANGO_DEBUG: False
    ports:
      - "8001:8000"
    command: /start_wsgi

  django_asgi:
    <<: *django
    environment:
      DJANGO_DEBUG: False
    ports:
      - "8002:8000"
    command: /start_asgi

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

  redis:
    image: redis:3.2
    ports:
      - "6379:6379"

  celeryworker:
    image: django_structlog_demo_project_local_django
    depends_on:
      - redis
      - postgres
    volumes:
      - .:/app:cached
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.redis
      - ./.envs/.local/.postgres

    command: /start-celeryworker
    tty: true # needed for colors to show in console logs

  celerybeat:
    image: django_structlog_demo_project_local_django
    depends_on:
      - redis
      - postgres
    volumes:
      - .:/app:cached
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.redis
      - ./.envs/.local/.postgres

    command: /start-celerybeat
    tty: true # needed for colors to show in console logs

  flower:
    image: django_structlog_demo_project_local_django
    ports:
      - "5555:5555"
    volumes:
      - .:/app:cached
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.redis
      - ./.envs/.local/.postgres
    command: /start-flower
