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 downTake 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
workspacecontainer.
- 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
websocketscontainer - 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/.envwhich can be overridden - The
workspacecontainer gives you somewhere to run your development/maintenance tasks
docker/.env- Change the
CADDY_HOST_LABELvariable 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_NAMEto some better name for your project, is used bydocker-composeto namespace the container and network names - Change the
DB_*variables to secure your database (generate random passwords!!), and also update your.envwith the same values.DB_DATABASEDB_USERDB_PASSWORDDB_ROOT_PASSWORD
- Change the
bootstrap.js- Laravel Echo is properly configured to use
laravel-websocketson the same host/port as the initial request. Will usewss://automatically if the site was loaded overhttps://.
- Laravel Echo is properly configured to use