services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: windor-lakes-api:latest
    container_name: windor-lakes-app
    restart: unless-stopped
    env_file:
      - .env
    environment:
      DB_HOST: host.docker.internal
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - ./.env:/var/www/html/.env:ro
      - ./storage:/var/www/html/storage

  queue:
    image: windor-lakes-api:latest
    container_name: windor-lakes-queue
    restart: unless-stopped
    depends_on:
      - app
    env_file:
      - .env
    environment:
      DB_HOST: host.docker.internal
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./.env:/var/www/html/.env:ro
      - ./storage:/var/www/html/storage
    command: >
      sh -lc "php artisan queue:work database --queue=default,quickbooks,quickbooks-wallet,quickbooks-accounts,quickbooks-catalog,quickbooks-customers --sleep=3 --tries=3 --max-time=3600"

  scheduler:
    image: windor-lakes-api:latest
    container_name: windor-lakes-scheduler
    restart: unless-stopped
    depends_on:
      - app
    env_file:
      - .env
    environment:
      DB_HOST: host.docker.internal
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./.env:/var/www/html/.env:ro
      - ./storage:/var/www/html/storage
    command: >
      sh -lc "while true; do php artisan schedule:run --no-interaction --verbose; sleep 60; done"
