Laravel Reverb with Docker

We simply pass the command to the Docker container and Laravel will start the Reverb process.

Usual Laravel Reverb Command

php artisan reverb:start

Important concepts

  1. You will need to follow the Laravel Reverb setup instructions to install the Laravel Reverb package into your Laravel application.
  2. In most cases, you probably want to run this as a separate container from your web container
  3. If you're using fpm-apache or fpm-nginx, might need to set the stop signal to SIGTERM for a graceful shutdown (see this PR for more details why)
  4. Be sure to set the health check
  5. You may need a proxy like Traefik to correctly route traffic to the right container
  6. If you need to run Reverb in the same container, you might want to look into writing your own S6 Overlay script to manage and monitor multiple processes in one container.

Run it with Docker

Example Docker Compose File

services:
  php:
    image: my/laravel-app
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.laravel.tls=true"
      - "traefik.http.routers.laravel.entrypoints=websecure"
      - "traefik.http.routers.laravel.rule=Host(`https://app.example.com`)"
      - "traefik.http.services.laravel.loadbalancer.server.port=8080"
      - "traefik.http.services.laravel.loadbalancer.server.scheme=http"

  reverb:
    image: my/laravel-app
    command: ["php", "/var/www/html/artisan", "--port=8000", "reverb:start"]
    stop_signal: SIGTERM # Set this for graceful shutdown if you're using fpm-apache or fpm-nginx
    healthcheck:
      # This is our native healthcheck script for Reverb
      test: ["CMD", "healthcheck-reverb"]
      start_period: 10s
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.reverb.tls=true"
      - "traefik.http.routers.reverb.entrypoints=websecure"
      - "traefik.http.routers.reverb.rule=Host(`https://reverb.example.com`)"
      - "traefik.http.services.reverb.loadbalancer.server.port=8000"
      - "traefik.http.services.reverb.loadbalancer.server.scheme=http"

Laravel ENV updates

Reverb may require a few ENV variables to be set in your Laravel application.

Laravel ENV VariableDescriptionValue if matching example above
REVERB_HOSTThe hostname the CLIENT will connect to.reverb.example.com
REVERB_PORTThe port the CLIENT will connect to.443
REVERB_SCHEMEThe scheme the CLIENT will connect to.https

Be sure to not get REVERB_HOST or REVERB_PORT confused with REVERB_SERVER_HOST or REVERB_SERVER_PORT. The _SERVER_ variables are for the SERVER (the Reverb daemon itself) and the others are for the CLIENT (people connecting to your application).

Get Up and Running The Easy Way

We do all the heavy lifting for you with Spin Pro. It's as easy as selecting it in a menu and we'll configure everything else for you. Learn how easy it is to get up and running with Reverb on Spin Pro.

Learn more about Laravel Reverb + Spin Pro →