services:
  mysql:
    image: mysql:8.4
    environment:
      MYSQL_DATABASE: workforce_saas
      MYSQL_USER: workforce
      MYSQL_PASSWORD: workforce_secret
      MYSQL_ROOT_PASSWORD: root_secret
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

  backend:
    image: php:8.2-cli
    working_dir: /app
    volumes:
      - ./backend:/app
    ports:
      - "8000:8000"
    command: php artisan serve --host=0.0.0.0 --port=8000
    depends_on:
      - mysql
      - redis

  frontend:
    image: node:20-alpine
    working_dir: /app
    volumes:
      - ./frontend:/app
    ports:
      - "5173:5173"
    command: sh -c "npm install && npm run dev -- --host 0.0.0.0"

  device-service:
    image: node:20-alpine
    working_dir: /app
    volumes:
      - ./device-service:/app
    ports:
      - "8090:8090"
    command: sh -c "npm install && npm run dev"
    depends_on:
      - redis

volumes:
  mysql_data:
