services:

  apache:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    container_name: laravel_apache
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - ../:/var/www/html
      - ./apache/000-default.conf:/etc/apache2/sites-available/000-default.conf
      - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - laravel_network
    depends_on:
      - mysql
    working_dir: /var/www/html

  mysql:
    image: mysql:8.0
    container_name: laravel_mysql
    restart: unless-stopped
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-laravel}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
      MYSQL_PASSWORD: ${DB_PASSWORD:-root}
      MYSQL_USER: ${DB_USERNAME:-laravel}
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - laravel_network

  node:
    image: node:18-alpine
    container_name: laravel_node
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ../:/var/www/html
      - /var/www/html/node_modules
    ports:
      - "5173:5173"
    command: sh -c "npm install && npm run dev"
    networks:
      - laravel_network
    depends_on:
      - apache

networks:
  laravel_network:
    driver: bridge

volumes:
  mysql_data:
    driver: local

