I have been trying to get this addressed so my Laravel application can talk to Laravel Reverb.
This is what I have for my docker-compose.reverb.yaml file:
services:
reverb:
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: ${DDEV_APPROOT}
container_name: "ddev-${DDEV_SITENAME}-reverb"
ports:
- '${REVERB_SERVER_PORT:-8080}:8080'
build:
context: .
dockerfile: reverb/Dockerfile
working_dir: /var/www/html
depends_on:
- redis
and this is what I have for my .ddev/reverb/Dockerfile
WORKDIR /var/www/html
RUN docker-php-ext-configure pcntl --enable-pcntl \
&& docker-php-ext-install \
pcntl
EXPOSE 8080
CMD [ "php", "artisan", "reverb:start", "--host=0.0.0.0" ]
After more tinkering and with the help of @rfay of DDEV and @Jsh, this is my working solution:
Update ~/.ddev/config.yaml to both expose the ports + deploy the daemon
web_extra_exposed_ports:
- name: vite
container_port: 5173
http_port: 5172
https_port: 5173
- name: reverb
container_port: 8080
http_port: 8081
https_port: 8080
web_extra_daemons:
- name: vite
command: bash -c 'npm install && npm run dev -- --host'
directory: /var/www/html
- name: reverb
command: bash -c 'php artisan reverb:start'
directory: /var/www/html
In my Laravel ~/.env file:
APP_HOST="myproject.ddev.site"
REVERB_APP_ID=1234
REVERB_APP_KEY=1234
REVERB_APP_SECRET=abcd
REVERB_HOST="${APP_HOST}"
REVERB_PORT=8080
REVERB_SCHEME=https
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
The solution that is working did not require any custom docker-compose config, nor a Dockerfile.
NOTE: Be mindful in not using APP_URL because this will include the protocol, https, where you want to only have the host because it will be connecting over ws: or wss: for the protocol.