services:
  laravel.test:
    build:
      context: ./vendor/laravel/sail/runtimes/8.4
      dockerfile: Dockerfile
      args:
        WWWGROUP: '${WWWGROUP:-1000}'
        NODE_VERSION: '20'
    image: tenantatlas-laravel
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    ports:
      - '${APP_PORT:-80}:80'
      - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
    environment:
      WWWUSER: '${WWWUSER:-1000}'
      WWWGROUP: '${WWWGROUP:-1000}'
      LARAVEL_SAIL: 1
      APP_SERVICE: laravel.test
    entrypoint: ["/bin/sh", "-c", "mkdir -p /var/www/html/node_modules && chown ${WWWUSER:-1000}:${WWWGROUP:-1000} /var/www/html/node_modules || true; exec start-container"]
    volumes:
      - '.:/var/www/html'
      - '/var/www/html/node_modules'
    networks:
      - sail
    depends_on:
      - pgsql
      - redis

  queue:
    build:
      context: ./vendor/laravel/sail/runtimes/8.4
      dockerfile: Dockerfile
      args:
        WWWGROUP: '${WWWGROUP:-1000}'
        NODE_VERSION: '20'
    image: tenantatlas-laravel
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    environment:
      WWWUSER: '${WWWUSER:-1000}'
      WWWGROUP: '${WWWGROUP:-1000}'
      LARAVEL_SAIL: 1
      APP_SERVICE: queue
    entrypoint: ["/bin/sh", "-c", "mkdir -p /var/www/html/node_modules && chown ${WWWUSER:-1000}:${WWWGROUP:-1000} /var/www/html/node_modules || true; exec start-container"]
    volumes:
      - '.:/var/www/html'
      - '/var/www/html/node_modules'
    networks:
      - sail
    depends_on:
      - laravel.test
      - pgsql
      - redis
    command: php artisan queue:work --tries=3 --timeout=300 --sleep=3 --max-jobs=1000

  pgsql:
    image: 'postgres:16'
    ports:
      - '${FORWARD_DB_PORT:-5432}:5432'
    environment:
      POSTGRES_DB: '${DB_DATABASE:-tenantatlas}'
      POSTGRES_USER: '${DB_USERNAME:-root}'
      POSTGRES_PASSWORD: '${DB_PASSWORD:-postgres}'
    volumes:
      - 'sail-pgsql:/var/lib/postgresql/data'
    networks:
      - sail

  redis:
    image: 'redis:7-alpine'
    ports:
      - '${FORWARD_REDIS_PORT:-6379}:6379'
    volumes:
      - 'sail-redis:/data'
    networks:
      - sail

volumes:
  sail-pgsql:
    driver: local
  sail-redis:
    driver: local

networks:
  sail:
    driver: bridge
