version: '3.8'

services:
  # PHP Application Service
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: investpro_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - investpro_network
    depends_on:
      - db
      - redis

  # Nginx Web Server
  webserver:
    image: nginx:alpine
    container_name: investpro_webserver
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - ./:/var/www
      - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - investpro_network
    depends_on:
      - app

  # MySQL Database
  db:
    image: mysql:8.0
    container_name: investpro_db
    restart: unless-stopped
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: investpro
      MYSQL_ROOT_PASSWORD: rootpassword123
      MYSQL_USER: investpro
      MYSQL_PASSWORD: investpro123
    volumes:
      - dbdata:/var/lib/mysql
      - ./docker/mysql/my.cnf:/etc/mysql/my.cnf
    networks:
      - investpro_network

  # Redis Cache
  redis:
    image: redis:alpine
    container_name: investpro_redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - investpro_network

  # MailHog for email testing
  mailhog:
    image: mailhog/mailhog
    container_name: investpro_mailhog
    ports:
      - "1025:1025"
      - "8025:8025"
    networks:
      - investpro_network

networks:
  investpro_network:
    driver: bridge

volumes:
  dbdata:
    driver: local
