Skip to content

Commit

Permalink
feat: add native Mercure support
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Nov 25, 2020
1 parent 64ed300 commit 6e86090
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Expand Up @@ -109,13 +109,16 @@ CMD ["php-fpm"]
FROM caddy:${CADDY_VERSION}-builder-alpine AS symfony_caddy_builder

RUN xcaddy build \
--with github.com/dunglas/mercure/caddy@main \
--with github.com/dunglas/mercure/caddy@main \
--with github.com/dunglas/vulcain/caddy

FROM caddy:${CADDY_VERSION} AS symfony_caddy

WORKDIR /srv/app

# Mercure UI
# TODO: add an option to Mrcure to set the path to static files
#COPY --from=dunglas/mercure:v0.11 /srv/public /srv/public/
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
6 changes: 5 additions & 1 deletion docker-compose.yml
Expand Up @@ -17,7 +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}
MERCURE_PUBLISH_URL: https://localhost/.well-known/mercure
# 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:
Expand All @@ -26,6 +27,9 @@ services:
target: symfony_caddy
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}
# Change these keys keys in production
MERCURE_PUBLISHER_JWT: ${MERCURE_PUBLISHER_JWT:-!ChangeMe!}
MERCURE_SUBSRIBER_JWT: ${MERCURE_SUBSRIBER_JWT:-!ChangeMe!}
restart: unless-stopped
ports:
- "80:80"
Expand Down
14 changes: 13 additions & 1 deletion docker/caddy/Caddyfile
Expand Up @@ -2,12 +2,24 @@
experimental_http3
}

{$SERVER_NAME}
{$SERVER_NAME}, caddy:80

log

route {
root * /srv/app/public
mercure {
# Enable the demo endpoint (you should disable it in production!)
#demo
# Publisher JWT key
publisher_jwt {$MERCURE_PUBLISHER_JWT}
# Subscriber JWT key
subscriber_jwt {$MERCURE_SUBSRIBER_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
Expand Down
1 change: 1 addition & 0 deletions docs/extra-services.md
Expand Up @@ -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

0 comments on commit 6e86090

Please sign in to comment.