# alarm.minifinder.com — PHP 7.4 (Apache) or PHP 8.3 (Apache + FPM)
# Run one profile at a time: --profile php74 or --profile php83
# php74: http://localhost:8080   php83: http://localhost:8081   pma: http://localhost:8082

services:
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
      MYSQL_DATABASE: ${DB_NAME:-alarmlog}
      MYSQL_USER: ${DB_USER:-alarmlog}
      MYSQL_PASSWORD: ${DB_PASS:-alarmlog}
    volumes:
      - mysql_data:/var/lib/mysql
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-allowed-packet=134217728
    ports:
      - "3307:3306"   # host 3307 to avoid conflict with local MySQL on 3306
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 5s
      timeout: 5s
      retries: 10

  app-74:
    build:
      context: .
      dockerfile: docker/php/Dockerfile.74
    profiles:
      - php74
    ports:
      - "8080:80"
    volumes:
      - .:/var/www/html
      - ${GOAPI_HOST_PATH:-../goapidev.minifinder.com}:/var/www/goapidev.minifinder.com
    environment:
      - DB_HOST=mysql
      - DB_USER=${DB_USER:-alarmlog}
      - DB_PASS=${DB_PASS:-alarmlog}
      - DB_NAME=${DB_NAME:-alarmlog}
      - APP_ENV=${APP_ENV:-local}
      - XDEBUG_MODE=${XDEBUG_MODE:-off}
      - GOAPI_MINIFINDER_PATH=/var/www/goapidev.minifinder.com
      - GOAPI_DB_HOST=mysql
      - GOAPI_DB_USER=${GOAPI_DB_USER:-gophpapibackup}
      - GOAPI_DB_PASS=${GOAPI_DB_PASS:-gophpapibackup}
      - GOAPI_DB_NAME=${GOAPI_DB_NAME:-gophpapibackup}
    depends_on:
      mysql:
        condition: service_healthy

  app-83-php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile.83
    profiles:
      - php83
    volumes:
      - .:/var/www/html
      - ${GOAPI_HOST_PATH:-../goapidev.minifinder.com}:/var/www/goapidev.minifinder.com
    environment:
      - DB_HOST=mysql
      - DB_USER=${DB_USER:-alarmlog}
      - DB_PASS=${DB_PASS:-alarmlog}
      - DB_NAME=${DB_NAME:-alarmlog}
      - APP_ENV=${APP_ENV:-local}
      - XDEBUG_MODE=${XDEBUG_MODE:-off}
      - GOAPI_MINIFINDER_PATH=/var/www/goapidev.minifinder.com
      - GOAPI_DB_HOST=mysql
      - GOAPI_DB_USER=${GOAPI_DB_USER:-gophpapibackup}
      - GOAPI_DB_PASS=${GOAPI_DB_PASS:-gophpapibackup}
      - GOAPI_DB_NAME=${GOAPI_DB_NAME:-gophpapibackup}
    depends_on:
      mysql:
        condition: service_healthy

  app-83-apache:
    build:
      context: ./docker/apache
      dockerfile: Dockerfile
    profiles:
      - php83
    ports:
      - "8081:80"
    volumes:
      - .:/var/www/html
      - ${GOAPI_HOST_PATH:-../goapidev.minifinder.com}:/var/www/goapidev.minifinder.com
    environment:
      - GOAPI_MINIFINDER_PATH=/var/www/goapidev.minifinder.com
    depends_on:
      - app-83-php

  pma:
    image: phpmyadmin:latest
    ports:
      - "8082:80"
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
      UPLOAD_LIMIT: 128M
    depends_on:
      mysql:
        condition: service_healthy

volumes:
  mysql_data:
