version: '3.8'

services:
  # MySQL Database
  mysql:
    image: mysql:8.0
    container_name: onlyfans_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: holosuiteindustr_onlyfans
      MYSQL_USER: holosuiteindustr_lbblanks
      MYSQL_PASSWORD: yesHu124!$
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
      - ./shared/database:/docker-entrypoint-initdb.d
    networks:
      - onlyfans_network

  # Redis (Optional - for caching)
  redis:
    image: redis:7-alpine
    container_name: onlyfans_redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - onlyfans_network

  # Laravel Backend
  laravel:
    build:
      context: ./laravel-backend
      dockerfile: Dockerfile
    container_name: onlyfans_laravel
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      - APP_ENV=production
      - DB_HOST=mysql
      - DB_DATABASE=holosuiteindustr_onlyfans
      - DB_USERNAME=holosuiteindustr_lbblanks
      - DB_PASSWORD=yesHu124!$
      - REDIS_HOST=redis
    volumes:
      - ./laravel-backend:/var/www/html
      - laravel_storage:/var/www/html/storage
    depends_on:
      - mysql
      - redis
    networks:
      - onlyfans_network

  # Node.js API
  nodejs:
    build:
      context: ./nodejs-api
      dockerfile: Dockerfile
    container_name: onlyfans_nodejs
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - LARAVEL_API_URL=http://laravel:8000
      - DB_HOST=mysql
      - DB_NAME=holosuiteindustr_onlyfans
      - DB_USER=holosuiteindustr_lbblanks
      - DB_PASS=yesHu124!$
      - REDIS_HOST=redis
    volumes:
      - ./nodejs-api:/app
      - nodejs_media:/app/media
      - nodejs_vault:/app/vault
    depends_on:
      - mysql
      - redis
      - laravel
    networks:
      - onlyfans_network

  # React Frontend
  react:
    build:
      context: ./react-frontend
      dockerfile: Dockerfile
    container_name: onlyfans_react
    restart: unless-stopped
    ports:
      - "3001:3001"
    environment:
      - REACT_APP_LARAVEL_API=http://localhost:8000
      - REACT_APP_NODEJS_API=http://localhost:3000
      - REACT_APP_SOCKET_URL=http://localhost:3000
    volumes:
      - ./react-frontend:/app
    depends_on:
      - laravel
      - nodejs
    networks:
      - onlyfans_network

  # Nginx Reverse Proxy
  nginx:
    image: nginx:alpine
    container_name: onlyfans_nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./deployment/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./deployment/ssl:/etc/nginx/ssl
    depends_on:
      - laravel
      - nodejs
      - react
    networks:
      - onlyfans_network

volumes:
  mysql_data:
  laravel_storage:
  nodejs_media:
  nodejs_vault:

networks:
  onlyfans_network:
    driver: bridge