version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: crm-app
    restart: unless-stopped
    ports:
      - "80:80"
      - "8080:8080"
    environment:
      - APP_NAME=CRM-Hostlino
      - APP_ENV=production
      - APP_DEBUG=false
      - APP_URL=${APP_URL:-http://localhost}
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=${DB_DATABASE:-crm}
      - DB_USERNAME=${DB_USERNAME:-crm}
      - DB_PASSWORD=${DB_PASSWORD:-secret}
      - CACHE_DRIVER=redis
      - SESSION_DRIVER=redis
      - QUEUE_CONNECTION=redis
      - REDIS_HOST=redis
      - REVERB_HOST=0.0.0.0
      - REVERB_PORT=8080
    volumes:
      - app-storage:/var/www/html/storage/app
      - app-logs:/var/www/html/storage/logs
    depends_on:
      - db
      - redis
    networks:
      - crm-network

  db:
    image: mysql:8.0
    container_name: crm-db
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE=${DB_DATABASE:-crm}
      - MYSQL_USER=${DB_USERNAME:-crm}
      - MYSQL_PASSWORD=${DB_PASSWORD:-secret}
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-rootsecret}
    volumes:
      - db-data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - crm-network

  redis:
    image: redis:alpine
    container_name: crm-redis
    restart: unless-stopped
    volumes:
      - redis-data:/data
    networks:
      - crm-network

volumes:
  db-data:
  redis-data:
  app-storage:
  app-logs:

networks:
  crm-network:
    driver: bridge
