feat: add built-in Mercure support (#89)
* feat: Mercure support * feat: add native Mercure support * improvements * feat: add Mercure UI * fix: typo * finish
This commit is contained in:
parent
05d7a189de
commit
7cb8668cb2
@ -5,7 +5,7 @@
|
||||
|
||||
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
|
||||
ARG PHP_VERSION=7.4
|
||||
ARG CADDY_VERSION=2.1.1
|
||||
ARG CADDY_VERSION=2
|
||||
|
||||
# "php" stage
|
||||
FROM php:${PHP_VERSION}-fpm-alpine AS symfony_php
|
||||
@ -109,12 +109,16 @@ CMD ["php-fpm"]
|
||||
FROM caddy:${CADDY_VERSION}-builder-alpine AS symfony_caddy_builder
|
||||
|
||||
RUN xcaddy build \
|
||||
--with github.com/dunglas/mercure@main \
|
||||
--with github.com/dunglas/mercure/caddy@main \
|
||||
--with github.com/dunglas/vulcain/caddy
|
||||
|
||||
FROM caddy:${CADDY_VERSION} AS symfony_caddy
|
||||
|
||||
WORKDIR /srv/app
|
||||
|
||||
ENV MERCURE_DEMO="demo /srv/mercure-assets/"
|
||||
COPY --from=dunglas/mercure:v0.11 /srv/public /srv/mercure-assets/
|
||||
COPY --from=symfony_caddy_builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY --from=symfony_php /srv/app/public public/
|
||||
COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile
|
||||
|
@ -14,8 +14,9 @@ A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony
|
||||
|
||||
* Production, development and CI ready
|
||||
* Automatic HTTPS (in dev and in prod!)
|
||||
* HTTP/2, HTTP/3 and [Server Push](https://symfony.com/doc/current/web_link.html) support
|
||||
* [Vulcain](https://vulcain.rocks)-enabled
|
||||
* HTTP/2, HTTP/3 and [Preload](https://symfony.com/doc/current/web_link.html) support
|
||||
* Built-in [Mercure](https://symfony.com/doc/current/mercure.html) hub
|
||||
* [Vulcain](https://vulcain.rocks) support
|
||||
* Just 2 services (PHP FPM and Caddy server)
|
||||
* Super-readable configuration
|
||||
|
||||
|
@ -5,3 +5,9 @@ services:
|
||||
php:
|
||||
environment:
|
||||
APP_ENV: prod
|
||||
|
||||
caddy:
|
||||
environment:
|
||||
MERCURE_DEMO: # Disable the demo
|
||||
MERCURE_PUBLISHER_JWT: ${MERCURE_PUBLISHER_JWT}
|
||||
MERCURE_SUBSCRIBER_JWT: ${MERCURE_SUBSCRIBER_JWT}
|
||||
|
@ -17,6 +17,8 @@ services:
|
||||
environment:
|
||||
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-symfony}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-13}
|
||||
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
|
||||
MERCURE_PUBLISH_URL: ${MERCURE_URL:-http://caddy/.well-known/mercure}
|
||||
SYMFONY_VERSION:
|
||||
|
||||
caddy:
|
||||
@ -24,7 +26,9 @@ services:
|
||||
context: .
|
||||
target: symfony_caddy
|
||||
environment:
|
||||
SERVER_NAME: ${SERVER_NAME:-localhost}
|
||||
SERVER_NAME: ${SERVER_NAME:-localhost, caddy:80}
|
||||
MERCURE_PUBLISHER_JWT: ${MERCURE_PUBLISHER_JWT:-!ChangeMe!}
|
||||
MERCURE_SUBSCRIBER_JWT: ${MERCURE_SUBSCRIBER_JWT:-!ChangeMe!}
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
|
@ -8,6 +8,20 @@ log
|
||||
|
||||
route {
|
||||
root * /srv/app/public
|
||||
mercure {
|
||||
# Transport to use (default to Bolt)
|
||||
transport_url bolt:///data/mercure.db
|
||||
# Enable the demo endpoint (disable it in production!)
|
||||
{$MERCURE_DEMO}
|
||||
# Publisher JWT key
|
||||
publisher_jwt {$MERCURE_PUBLISHER_JWT}
|
||||
# Subscriber JWT key
|
||||
subscriber_jwt {$MERCURE_SUBSCRIBER_JWT}
|
||||
# Allow anonymous subscribers (double-check that it's what you want)
|
||||
anonymous
|
||||
# Enable the subscription API (double-check that it's what you want)
|
||||
subscriptions
|
||||
}
|
||||
vulcain
|
||||
push
|
||||
php_fastcgi php:9000
|
||||
|
@ -17,6 +17,8 @@ For instance, use the following command to use the `master` branch of Symfony:
|
||||
|
||||
## Customizing the Server Name
|
||||
|
||||
Use the `SERVER_NAME` environment variable to define your custom server name.
|
||||
Use the `SERVER_NAME` environment variable to define your custom server name(s).
|
||||
|
||||
$ SERVER_NAME=symfony.wip docker-compose up --build
|
||||
$ SERVER_NAME="symfony.wip, caddy:80" docker-compose up --build
|
||||
|
||||
If you use Mercure, keep `caddy:80` in the list to allow the PHP container to request the caddy service.
|
||||
|
@ -6,4 +6,5 @@ the recipe will automatically modify the `Dockerfile` and `docker-compose.yml` t
|
||||
The currently supported packages are:
|
||||
|
||||
* `symfony/orm-pack`: install a PostgreSQL service
|
||||
* `symfony/mercure-bundle`: use the Mercure.rocks module shipped with Caddy
|
||||
* `symfony/messenger`: install a RabbitMQ service
|
||||
|
Loading…
x
Reference in New Issue
Block a user