version: "3.9"

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: school_app
    working_dir: /var/www
    user: "0:0"   # run as root to avoid permission issues
    volumes:
      - ./:/var/www
      - ./php.ini:/usr/local/etc/php/conf.d/custom.ini
    environment:
      - APP_ENV=local
      - APP_DEBUG=true
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=school
      - DB_USERNAME=root
      - DB_PASSWORD=root
    depends_on:
      - db
    networks:
      - laravel

  node:
    image: node:24
    container_name: node_app
    working_dir: /var/www
    user: "0:0"
    volumes:
      - ./:/var/www
    command: tail -f /dev/null  
    networks:
      - laravel

  db:
    image: mysql:8.4
    container_name: mysql_database
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: school
      MYSQL_ROOT_PASSWORD: root
      MYSQL_PASSWORD: root
      MYSQL_USER: laravel
    ports:
      - "3306:3306"
    volumes:
      - dbdata:/var/lib/mysql
    networks:
      - laravel

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: unless-stopped
    ports:
      - "8092:80"
    environment:
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: root
    networks:
      - laravel

  nginx:
    image: nginx:latest
    container_name: laravel_nginx
    ports:
      - "8090:80"
    volumes:
      - ./:/var/www
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app
    networks:
      - laravel

networks:
  laravel:

volumes:
  dbdata:
