services:
  # Servicio de aplicación Laravel (PRUEBA)
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: all-panels-app-test
    restart: unless-stopped
    ports:
      - "${APP_PORT:-9000}:80"
    environment:
      - APP_NAME=${APP_NAME:-AllPanels Test}
      - APP_ENV=${APP_ENV:-local}
      - APP_DEBUG=${APP_DEBUG:-true}
      - APP_URL=${APP_URL:-http://localhost:9000}
      - DB_CONNECTION=mysql
      - DB_HOST=mysql-test
      - DB_PORT=3306
      - DB_DATABASE=${DB_DATABASE:-all-panel-test}
      - DB_USERNAME=${DB_USERNAME:-all_panel_test_user}
      - DB_PASSWORD=${DB_PASSWORD:-test_password_123}
      - CACHE_DRIVER=file
      - QUEUE_CONNECTION=sync
      - SESSION_DRIVER=file
      - SESSION_LIFETIME=120
    volumes:
      - ./:/var/www/html
      - storage_data_test:/var/www/html/storage/app
      - logs_data_test:/var/www/html/storage/logs
    depends_on:
      mysql-test:
        condition: service_healthy
    networks:
      - all-panels-network-test

  # Servicio MySQL (PRUEBA)
  mysql-test:
    image: mysql:8.0
    container_name: all-panels-mysql-test
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-test_root_password}
      - MYSQL_DATABASE=${DB_DATABASE:-all-panel-test}
      - MYSQL_USER=${DB_USERNAME:-all_panel_test_user}
      - MYSQL_PASSWORD=${DB_PASSWORD:-test_password_123}
    ports:
      - "${MYSQL_EXTERNAL_PORT:-33061}:3306"
    volumes:
      - mysql_data_test:/var/lib/mysql
      - ./all-panel04082025.sql:/docker-entrypoint-initdb.d/all-panel04082025.sql:ro
      - ./docker/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh:ro
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-test_root_password}"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    networks:
      - all-panels-network-test

  # PhpMyAdmin (PRUEBA)
  phpmyadmin-test:
    image: phpmyadmin/phpmyadmin
    container_name: all-panels-phpmyadmin-test
    restart: unless-stopped
    environment:
      - PMA_HOST=mysql-test
      - PMA_PORT=3306
      - PMA_USER=${DB_USERNAME:-all_panel_test_user}
      - PMA_PASSWORD=${DB_PASSWORD:-test_password_123}
      - UPLOAD_LIMIT=500M
    ports:
      - "${PHPMYADMIN_PORT:-9090}:80"
    depends_on:
      - mysql-test
    networks:
      - all-panels-network-test
    profiles:
      - dev

networks:
  all-panels-network-test:
    driver: bridge

volumes:
  mysql_data_test:
    driver: local
  storage_data_test:
    driver: local
  logs_data_test:
    driver: local
