version: "3.9"

services:
  backend:
    build:
      context: ./backend
      dockerfile: ../docker/backend.Dockerfile
    container_name: wpm_backend
    restart: unless-stopped
    volumes:
      - ./backend:/var/www/html
    environment:
      - APP_ENV=production
    depends_on:
      - mysql
      - redis
    networks:
      - wpm_network

  horizon:
    build:
      context: ./backend
      dockerfile: ../docker/backend.Dockerfile
    container_name: wpm_horizon
    restart: unless-stopped
    command: php artisan horizon
    volumes:
      - ./backend:/var/www/html
    depends_on:
      - mysql
      - redis
    networks:
      - wpm_network

  scheduler:
    build:
      context: ./backend
      dockerfile: ../docker/backend.Dockerfile
    container_name: wpm_scheduler
    restart: unless-stopped
    command: sh -c "while true; do php artisan schedule:run; sleep 60; done"
    volumes:
      - ./backend:/var/www/html
    depends_on:
      - mysql
      - redis
    networks:
      - wpm_network

  reverb:
    build:
      context: ./backend
      dockerfile: ../docker/backend.Dockerfile
    container_name: wpm_reverb
    restart: unless-stopped
    command: php artisan reverb:start --host=0.0.0.0 --port=8080
    ports:
      - "8080:8080"
    volumes:
      - ./backend:/var/www/html
    depends_on:
      - mysql
      - redis
    networks:
      - wpm_network

  nginx:
    image: nginx:1.27-alpine
    container_name: wpm_nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./backend:/var/www/html
      - ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./docker/ssl:/etc/nginx/ssl:ro
    depends_on:
      - backend
    networks:
      - wpm_network

  frontend:
    build:
      context: ./frontend
      dockerfile: ../docker/frontend.Dockerfile
    container_name: wpm_frontend
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - NEXT_PUBLIC_API_URL=https://your-domain.com/api/v1
    networks:
      - wpm_network

  mysql:
    image: mysql:8.0
    container_name: wpm_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-change_me_root}
      MYSQL_DATABASE: ${DB_DATABASE:-wpm_platform}
      MYSQL_USER: ${DB_USERNAME:-wpm_user}
      MYSQL_PASSWORD: ${DB_PASSWORD:-change_me}
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - wpm_network

  redis:
    image: redis:7.2-alpine
    container_name: wpm_redis
    restart: unless-stopped
    command: redis-server --requirepass ${REDIS_PASSWORD:-change_me}
    volumes:
      - redis_data:/data
    networks:
      - wpm_network

  minio:
    image: minio/minio:latest
    container_name: wpm_minio
    restart: unless-stopped
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER:-wpm_admin}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-change_me_minio}
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - minio_data:/data
    networks:
      - wpm_network

networks:
  wpm_network:
    driver: bridge

volumes:
  mysql_data:
  redis_data:
  minio_data:
