version: "3.8"

services:
  db:
    image: mysql:5.7
    container_name: mysql57
    environment:
      MYSQL_DATABASE: infoapp2
      MYSQL_USER: appuser                 # 👈 usuario de la app (NO root)
      MYSQL_PASSWORD: AppPass123!         # 👈 clave del usuario app
      MYSQL_ROOT_PASSWORD: Abcd1234.      # 👈 clave de root
      TZ: America/Bogota
    command: [
      "--character-set-server=utf8mb4",
      "--collation-server=utf8mb4_unicode_ci",
      "--sql-mode="
    ]
    ports:
      - "3307:3306"                       # opcional, para acceder desde tu host
    volumes:
      - dbdata:/var/lib/mysql
      - ./docker/mysql/initdb.d:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p$MYSQL_ROOT_PASSWORD || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 10

  phpmyadmin:
    image: phpmyadmin:5
    container_name: pma
    environment:
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: Abcd1234.            # 👈 igual que MYSQL_ROOT_PASSWORD
    depends_on:
      - db
    ports:
      - "8082:80"

  web:
    build:
      context: .
      dockerfile: docker/Dockerfile.php72
    container_name: cake-web
    depends_on:
      - db
    ports:
      - "8080:80"
      - "8765:8765"
    volumes:
      - ./back-end:/var/www/html
    environment:
      TZ: America/Caracas

  front:
    build:
      context: .
      dockerfile: docker/Dockerfile.front
    container_name: react-front
    ports:
      - "8081:80"
    depends_on:
      - web

volumes:
  dbdata: