# Vereego Docker Compose - Development Configuration
# Use: docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

services:
  # ==========================================================================
  # Development PHP-FPM with Xdebug and source mounting
  # ==========================================================================
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile.dev
    environment:
      - APP_ENV=local
      - APP_DEBUG=true
      - XDEBUG_MODE=develop,debug
      - XDEBUG_CONFIG=client_host=host.docker.internal
    volumes:
      # Mount source code for live editing
      - .:/var/www/html:cached
      # Persist vendor inside container (not overwritten by host mount)
      - vendor:/var/www/html/vendor
      # In dev, override the app-storage volume to use local files
      - ./storage:/var/www/html/storage:cached
      - ./bootstrap/cache:/var/www/html/bootstrap/cache:cached
      # Mount public folder for QR codes and other assets
      - ./public:/var/www/html/public:cached
    extra_hosts:
      - "host.docker.internal:host-gateway"

  # ==========================================================================
  # Vite Dev Server for HMR
  # ==========================================================================
  vite:
    image: node:20-alpine
    container_name: vereego-vite
    working_dir: /app
    command: sh -c "npm install && npx vite --host 0.0.0.0 --port 5173"
    volumes:
      - .:/app:cached
    ports:
      - "5173:5173"
    networks:
      - vereego-network

  # ==========================================================================
  # Nginx - development adjustments
  # ==========================================================================
  nginx:
    volumes:
      - .:/var/www/html:cached
      # Mount storage/app/public to public/storage for serving uploaded files
      - ./storage/app/public:/var/www/html/public/storage:cached

  # ==========================================================================
  # pgAdmin for database management
  # ==========================================================================
  pgadmin:
    image: dpage/pgadmin4:latest
    container_name: vereego-pgadmin
    restart: unless-stopped
    environment:
      - PGADMIN_DEFAULT_EMAIL=admin@vereego.com
      - PGADMIN_DEFAULT_PASSWORD=admin
      - PGADMIN_CONFIG_SERVER_MODE=False
    ports:
      - "8080:80"
    depends_on:
      - db
    networks:
      - vereego-network

  # ==========================================================================
  # Mailpit for email testing
  # ==========================================================================
  mailpit:
    image: axllent/mailpit:latest
    container_name: vereego-mailpit
    restart: unless-stopped
    ports:
      - "8025:8025" # Web UI
      - "1025:1025" # SMTP
    networks:
      - vereego-network

  # ==========================================================================
  # Redis Commander for Redis management
  # ==========================================================================
  redis-commander:
    image: rediscommander/redis-commander:latest
    container_name: vereego-redis-commander
    restart: unless-stopped
    environment:
      - REDIS_HOSTS=local:redis:6379
    ports:
      - "8081:8081"
    depends_on:
      - redis
    networks:
      - vereego-network

# Additional volumes for development
volumes:
  vendor:
    name: vereego-vendor
