version: '3.8'

services:
  laravel:
    build:
      context: .
      dockerfile: ./LaravelDockerFile
    ports:
      - "8000:8000"
    environment:
      - APP_ENV=local
      - APP_DEBUG=true
      - DB_HOST=mysql
      - DB_DATABASE=laravel
      - DB_USERNAME=root
      - DB_PASSWORD=password
    volumes:
      - ./backend:/var/www/html
      - ./backend/storage:/var/www/html/storage
    networks:
      - laravel

  mysql:
    image: mysql:8.0
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: laravel
      MYSQL_USER: root
      MYSQL_PASSWORD: password
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - laravel

  angular:
    build:
      context: ./angular-app
      dockerfile: ./Dockerfile
    ports:
      - "4200:80" # Expose the Angular app
    networks:
      - laravel

  proxy:
    image: nginx:alpine
    ports:
      - "8080:80"
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - laravel
      - angular
    networks:
      - laravel

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - "8081:80"  # Changed to avoid conflict with proxy
    environment:
      PMA_HOST: mysql
      MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'  # Use the same password you set for MYSQL_ROOT_PASSWORD in the mysql service
    depends_on:
      - mysql
    networks:
      - laravel

networks:
  laravel:
    driver: bridge

volumes:
  mysql_data:
