This repo is meant to show an example of how a project with Laravel-Websockets run using Docker and using Caddy as the server.
# Prep
$ cp .env.example .env
$ cp docker/.env.example docker/.env
# To spin up the Docker stack (build will take time)
$ docker/utils up
# To get a shell to play around with PHP, Yarn, etc.
$ docker/utils shell
# Run tests
$ docker/utils test
# See the 'utils' help
$ docker/utils
# Run 'docker-compose ps' on the stack
$ docker/utils dc ps
# Tear it down
$ docker/utils down
Take a look at the individual commits to see the general idea of the setup.
This README assumes you already know how to use Laravel, in general.
docker/utils
- Helper shell script for running the app, quick access to common maintenance tasks, getting a shell into the
workspace
container.
- Helper shell script for running the app, quick access to common maintenance tasks, getting a shell into the
Caddyfile
- Runs the Laravel app with php-fpm
- Proxies any requests with websocket headers to the
websockets
container - Serves static files
- Please ask on https://caddy.community for any Caddy usage questions!
docker-compose.yml
- Service definitions for everything you need to run the app
- Uses variables from
docker/.env
which can be overridden - The
workspace
container gives you somewhere to run your development/maintenance tasks
docker/.env
- Change the
CADDY_HOST_LABEL
variable to your domain name to serve the app automatically over HTTPS with certificates fetched from Let's Encrypt (please read the Caddy docs!) - Change the
COMPOSE_PROJECT_NAME
to some better name for your project, is used bydocker-compose
to namespace the container and network names - Change the
DB_*
variables to secure your database (generate random passwords!!), and also update your.env
with the same values.DB_DATABASE
DB_USER
DB_PASSWORD
DB_ROOT_PASSWORD
- Change the
bootstrap.js
- Laravel Echo is properly configured to use
laravel-websockets
on the same host/port as the initial request. Will usewss://
automatically if the site was loaded overhttps://
.
- Laravel Echo is properly configured to use