version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: laravel-app
    ports:
      - "8000:8000"
    volumes:
      - .:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - db
    environment:
      COMPOSER_ALLOW_SUPERUSER: 1
    command: sh -c "composer install --ignore-platform-req=ext-gd --ignore-platform-req=ext-exif && php artisan serve --host=0.0.0.0 --port=8000"

  db:
    image: mysql:8.0
    container_name: mysql-db
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: karna
      MYSQL_USER: root
      MYSQL_PASSWORD: root
    volumes:
      - db_data:/var/lib/mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    depends_on:
      - db
    ports:
      - "8080:80"
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: root
      UPLOAD_LIMIT: 200M
      MAX_EXECUTION_TIME: 1000
      MEMORY_LIMIT: 512M
      TZ: Asia/Makassar
      SESSION_SAVE_PATH: /tmp
    volumes:
      - ./php.ini:/usr/local/etc/php/php.ini

  node:
    image: node:18
    container_name: node-container
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
    ports:
      - "5173:5173"  # Expose Vite port
    command: sh -c "npm install && npm run dev"

volumes:
  db_data:
