services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: bazarbaby/app:local
    restart: unless-stopped
    user: "${APP_UID:-1000}:${APP_GID:-1000}"
    network_mode: host
    env_file:
      - .env
    volumes:
      - ./:/var/www/html

  queue:
    build:
      context: .
      dockerfile: Dockerfile
    image: bazarbaby/app:local
    restart: unless-stopped
    user: "${APP_UID:-1000}:${APP_GID:-1000}"
    network_mode: host
    command: php artisan queue:work --sleep=3 --tries=3 --timeout=90
    env_file:
      - .env
    volumes:
      - ./:/var/www/html

  scheduler:
    build:
      context: .
      dockerfile: Dockerfile
    image: bazarbaby/app:local
    restart: unless-stopped
    user: "${APP_UID:-1000}:${APP_GID:-1000}"
    network_mode: host
    command: php artisan schedule:work
    env_file:
      - .env
    volumes:
      - ./:/var/www/html

  mailhog:
    image: mailhog/mailhog:v1.0.1
    restart: unless-stopped
    network_mode: host
    command:
      - -smtp-bind-addr=127.0.0.1:1025
      - -ui-bind-addr=127.0.0.1:8025
      - -api-bind-addr=127.0.0.1:8025

  test:
    image: bazarbaby/app:local
    profiles: ["test"]
    user: "${APP_UID:-1000}:${APP_GID:-1000}"
    network_mode: host
    command: php artisan test
    environment:
      APP_ENV: testing
      CACHE_STORE: array
      DB_CONNECTION: sqlite
      DB_DATABASE: ":memory:"
      LOG_CHANNEL: stderr
      QUEUE_CONNECTION: sync
      SESSION_DRIVER: array
    volumes:
      - ./:/var/www/html

# PostgreSQL e Nginx são serviços do host e, intencionalmente, não fazem parte deste Compose.
# MailHog recebe e-mails locais via SMTP em 127.0.0.1:1025 e oferece a interface em http://localhost:8025.
