version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: whatsapp-saas-app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
      - ./storage:/var/www/html/storage
    ports:
      - "8000:8000"
    environment:
      - APP_ENV=${APP_ENV:-production}
      - APP_DEBUG=${APP_DEBUG:-false}
    depends_on:
      - db
      - redis
    networks:
      - whatsapp-network

  db:
    image: mysql:8.0
    container_name: whatsapp-saas-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-whatsapp_saas}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-password}
      MYSQL_PASSWORD: ${DB_PASSWORD:-password}
      MYSQL_USER: ${DB_USERNAME:-whatsapp}
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - whatsapp-network

  redis:
    image: redis:7-alpine
    container_name: whatsapp-saas-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - whatsapp-network

  whatsapp-service:
    build:
      context: .
      dockerfile: Dockerfile.whatsapp
    container_name: whatsapp-saas-service
    restart: unless-stopped
    working_dir: /app
    volumes:
      - ./storage/whatsapp-sessions:/app/storage/whatsapp-sessions
    ports:
      - "3000:3000"
    environment:
      - LARAVEL_API_URL=http://app:8000
      - API_TOKEN=${WHATSAPP_API_TOKEN:-}
      - WHATSAPP_SERVICE_PORT=3000
    depends_on:
      - app
    networks:
      - whatsapp-network

volumes:
  db_data:

networks:
  whatsapp-network:
    driver: bridge

