version: '3.7'
services:
db:
image: mariadb:10.2.29
ports:
- "3307:3306" #outside:inside docker container from within
environment:
- MYSQL_DATABASE=test_db
- MYSQL_ROOT_PASSWORD=toor
volumes:
- persistent:/var/lib/mysql
- ./docker/build/db/:/docker-entrypoint-initdb.d/
networks:
- symfony
nginx:
build:
context: ./docker
dockerfile: Dockerfile-nginx
volumes:
- ./:/var/www/project/:cached
ports:
- 8080:80 # Ports that are exposed, you can connect to port 8001 to port 80 of the container.
links:
- php
- mercure
networks:
- symfony
php:
build:
context: ./docker
dockerfile: Dockerfile-php
expose:
- 2443
environment:
- DATABASE_URL=mysql://root:toor@db/test_db
volumes:
- ./:/var/www/project/:cached # Location of the project for php-fpm. Note this should be the same for NGINX.*
- ./docker/build/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./docker/build/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
links:
- mercure
networks:
- symfony
###> symfony/mercure-bundle ###
mercure:
image: dunglas/mercure
restart: unless-stopped
ports:
- 8081:3000
environment:
SERVER_NAME: ':3000'
MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_SECRET}
MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_JWT_SECRET}
# Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive
MERCURE_EXTRA_DIRECTIVES: |-
cors_origins *
anonymous
command: /usr/bin/caddy run --config /etc/caddy/Caddyfile.dev
volumes:
- mercure_data:/data
- mercure_config:/config
networks:
- symfony
volumes:
mercure_data:
mercure_config:
persistent:
networks:
symfony:
config/packages/mercure.yaml
mercure:
hubs:
default:
url: '%env(MERCURE_PUBLIC_URL)%'
jwt:
secret: '%env(MERCURE_JWT_SECRET)%'
publish: [ '*' ]
I have this configuration for my symfony application. The Mercure hub is running fine on localhost:8081. If I send an update over the UI of the hub, my javascript client can receive the update.
The problem is I can not publish an update with HubInterface
like this.
$update = new Update('https://example.com/my-private-topic', json_encode($message));
$hub->publish($update);
This said: failed to send an update and nothing more.
I tried to use another JWT according to documentation of symfony 6.3.
// Publisher's JWT must contain this topic, a URI template it matches or * in mercure.publish or you'll get a 401
// Subscriber's JWT must contain this topic, a URI template it matches or * in mercure.subscribe to receive the update
But obvisiously it did not help.
I tried to configure in yaml file like this but nothing happend
framework:
http_client:
default_options:
verify_peer: false