services:
  mysql:
    image: mysql:8.4
    container_name: invoice-mysql
    restart: unless-stopped
    ports:
      - "${DB_PORT:-3306}:3306"
    environment:
      MYSQL_DATABASE: ${DB_NAME:-invoice}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
    volumes:
      - mysql_data_v2:/var/lib/mysql
    healthcheck:
      test:
        - CMD-SHELL
        - mysqladmin ping -h 127.0.0.1 -uroot -p$${MYSQL_ROOT_PASSWORD} --silent
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 20s

  phpmyadmin:
    image: phpmyadmin:5.2-apache
    container_name: invoice-phpmyadmin
    restart: unless-stopped
    depends_on:
      mysql:
        condition: service_healthy
    ports:
      - "${PHPMYADMIN_PORT:-8080}:80"
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_USER: ${DB_USER:-root}
      PMA_PASSWORD: ${DB_PASSWORD:-root}

volumes:
  mysql_data_v2:
