services:
  mysql:
    image: mysql:8.0
    container_name: INNOVA_mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: INNOVA_intra
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_USER: INNOVA_user
      MYSQL_PASSWORD: INNOVA_password
    ports:
      - "3307:3306" # Puerto 3307 en host para evitar conflicto con MySQL existente
    volumes:
      - INNOVA_mysql_data:/var/lib/mysql
      # ./../viejo/db.sql es un directorio, no un archivo — deshabilitado. Si tenés un dump .sql, montalo aquí o importalo después.
      # - ./../viejo/db.sql:/docker-entrypoint-initdb.d/db.sql:ro
    networks:
      - INNOVA_network
    healthcheck:
      test:
        [
          "CMD",
          "mysqladmin",
          "ping",
          "-h",
          "localhost",
          "-uroot",
          "-proot_password",
        ]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s

  php-fpm:
    build:
      context: .
      dockerfile: Dockerfile.php
    container_name: INNOVA_php-fpm
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
      - INNOVA_php_data:/var/www/html/storage
      - ./storage/cert:/var/www/html/storage/cert:ro  # Certificados DTE desde host
    networks:
      - INNOVA_network
    depends_on:
      mysql:
        condition: service_healthy
    environment:
      - DB_HOST=mysql
      - DB_PORT=3306
      - DB_DATABASE=INNOVA_intra
      - DB_USERNAME=INNOVA_user
      - DB_PASSWORD=INNOVA_password

  nginx:
    image: nginx:alpine
    container_name: INNOVA_nginx
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - .:/var/www/html
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
    networks:
      - INNOVA_network
    depends_on:
      - php-fpm

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: INNOVA_phpmyadmin
    restart: unless-stopped
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: root_password
      UPLOAD_LIMIT: 300M
    ports:
      - "8080:80"
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - INNOVA_network

volumes:
  INNOVA_mysql_data:
    name: INNOVA_mysql_data
  INNOVA_php_data:
    name: INNOVA_php_data

networks:
  INNOVA_network:
    name: INNOVA_network
    driver: bridge
