services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: lead2hire_app
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    ports:
      - "8000:8000"
    depends_on:
      - mysql
    command: >
      bash -c "composer install &&
               php artisan key:generate &&
               php artisan migrate &&
               php artisan serve --host=0.0.0.0 --port=8000"

  mysql:
    image: mysql:8.0
    container_name: lead2hire_mysql
    restart: always
    environment:
      MYSQL_DATABASE: lead2hire
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "3306:3306"

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: lead2hire_pma
    restart: always
    environment:
      PMA_HOST: mysql
      PMA_USER: root
      PMA_PASSWORD: root
    ports:
      - "8080:80"
    depends_on:
      - mysql

volumes:
  db_data:
