runtime-playground
runtime-playground copied to clipboard
Demo of a new project using the new Runtime Symfony component (PHP-FPM, RoadRunner, and Swoole).
This Project
This is a working example of Symfony's Runtime component. Do not use this project, look through the code and pull out the parts you find interesting. Copy+paste is your friend.
Contains:
- Symfony v5.3 skeleton,
- Docker Stack for both FPM, Swoole and RoadRunner, and
- A handy Makefile for the SSL stuff.
How?
Depending on the Docker build target (fpm, swoole, or roadrunner) the PHP container does the following:
- For build target
fpm:- Execute
php-fpm --nodaemonize APP_RUNTIMEis set toSymfony\Component\Runtime\SymfonyRuntime
- Execute
- For build target
swoole:- Execute
php "<project-dir>/public/index.php" APP_RUNTIMEis set toRuntime\Swoole\Runtime- Environment variables
SWOOLE_HOSTandSWOOLE_PORTare set.
- Execute
- For build target
roadrunner- Execute
/sbin/rr serve APP_RUNTIMEis set toRuntime\RoadRunnerSymfonyNyholm\Runtime.rr.yamlconfiguration file is created
- Execute
In the Nginx container, build target fpm uses FastCGI, while build targets swoole and roadrunner use Reverse Proxy.
Setup Locally
- You will need
git,openssl,make, andmkcert. - Update values in
.env(choosefpm,swooleorroadrunnerfor${RUNTIME}). docker-compose build --pullmake passwordmake mock-sslcomposer install(orbin/env composer installto run it inside the PHP container)docker-compose up -dmkcert -install- Go to
https://${DOMAIN}:${SSL_PORT}
Production
You probably shouldn't use this for production, but if you did:
sudo mkdir -p "/etc/letsencrypt/challenges"docker-compose -f "docker-compose.yaml" run -d --name "acme" server nginx -c "/etc/nginx/acme.conf"sudo certbot certonly --webroot --webroot-path="/etc/letsencrypt/challenges" --cert-name="docker" -d "${YOUR_DOMAIN}"sudo openssl dhparam -out "/etc/letsencrypt/dhparam.pem" 4096