services:
  web:
    container_name: app_caracole
    build:
      context: ./app
      dockerfile: Dockerfile
    command: gunicorn caracole_ph_api.wsgi:application --bind 0.0.0.0:8001 --timeout 30 # --reload  
    ports:
      - 8001:8001
    env_file:
      - ./app/.env
    volumes:
      - static_volume:/usr/src/app/staticfiles
      - media_volume:/usr/src/app/mediafiles
      - ./app/:/usr/src/app/
      - product_inquiries_reports_volume:/usr/src/app/inquiry/reports
      - general_inquiries_reports_volume:/usr/src/app/contact_us/reports
    expose:
      - 8001
    restart: always
    depends_on:
      - postgres
    networks:
      - iso_network
  
  postgres:
    container_name: db_caracole
    image: postgres
    env_file:
      - ./app/.env
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: always
    expose:
      - 5433
    networks:
      - iso_network

  redis:
    container_name: redis_caracole
    image: redis:7-alpine
    restart: always
    networks:
      - iso_network
  
  celery_worker:
    container_name: cworker_caracole
    build:
      context: ./app
      dockerfile: Dockerfile
    command: celery -A caracole_ph_api worker -l info
    volumes:
      - .:/app
      - product_inquiries_reports_volume:/usr/src/app/inquiry/reports
      - general_inquiries_reports_volume:/usr/src/app/contact_us/reports
    env_file:
      - ./app/.env
    restart: always 
    depends_on:
      - redis
      - web
    networks:
      - iso_network

  celery_beat:
    container_name: cbeat_caracole
    build:
      context: ./app
      dockerfile: Dockerfile
    command: celery -A caracole_ph_api beat -l info
    volumes:
      - .:/app
      - product_inquiries_reports_volume:/usr/src/app/inquiry/reports
      - general_inquiries_reports_volume:/usr/src/app/contact_us/reports
    env_file:
      - ./app/.env
    restart: always
    depends_on:
      - redis
      - web
    networks:
      - iso_network

volumes:
  static_volume:
  media_volume:
  product_inquiries_reports_volume:
  general_inquiries_reports_volume:
  postgres_data:

networks:
  iso_network:
    driver: bridge