version: '3.9'

services:
  web:
    build:
      context: ./backend
    command: sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
    env_file:
      - .env
    volumes:
      - ./backend:/app
    ports:
      - "8000:8000"
    depends_on:
      - db
      - redis

  worker:
    build:
      context: ./backend
    command: celery -A config worker -l info
    env_file:
      - .env
    volumes:
      - ./backend:/app
    depends_on:
      - db
      - redis

  beat:
    build:
      context: ./backend
    command: celery -A config beat -l info
    env_file:
      - .env
    volumes:
      - ./backend:/app
    depends_on:
      - db
      - redis

  db:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data

  redis:
    image: redis:7
    restart: unless-stopped
    ports:
      - "6379:6379"

volumes:
  pgdata:
