Failing to get Mercure Hub up and running in Platform.sh
The information in this post is accurate as of the published date . Please make sure to check any linked documentation within the post for changes/updates.
I have the following applications.yaml configured in a Symfony app,
```
api:
type: php:8.1
runtime:
extensions:
- apcu
- mbstring
- sodium
- ctype
- iconv
- pdo_pgsql
# Relationships enable an app container's access to a service.
relationships:
database: "database:postgresql"
mercure: "mercure:http"
build:
flavor: none
disk: 512
web:
locations:
'/':
root: "public"
expires: 1h
passthru: "/index.php"
headers:
Access-Control-Allow-Origin: "*"
mounts:
'/var': { source: local, source_path: var }
hooks:
build: |
set -x -e
curl -fs https://get.symfony.com/cloud/configurator | bash
NODE_VERSION=18 symfony-build
deploy: |
set -x -e
symfony-deploy
mercure:
type: golang:1.22
build:
flavor: 'none'
disk: 1024
variables:
env:
MERCUREVERSION: v0.16.2
MERCURE_TRANSPORT_URL: 'bolt://database/mercure.db'
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
# MERCURE_PUBLISHER_JWT_ALG: 'HS256'
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
# MERCURE_SUBSCRIBER_JWT_ALG: 'HS256'
MERCURE_EXTRA_DIRECTIVES: |
# Allow all CORS origins
cors_origins *
# Allow all publishers
publish_origins *
# Enable the subscription endpoint (default is enabled)
subscriptions
# Enable the publishing endpoint (default is enabled)
publish
# Enable UI
ui
web:
commands:
start: ./mercure run
locations:
/:
passthru: true
scripts: false
request_buffering:
enabled: false
headers:
Access-Control-Allow-Origin: '*'
mounts:
'database': { source: local, source_path: 'database' }
'/.local': { source: local, source_path: '.local' }
'/.config': { source: local, source_path: '.config' }
hooks:
build: ./mercure.sh
```
The mercure binary downloads but when it is run, I get the following error,
```
Error: loading initial config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 0: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 4: loading handler modules: position 1: loading module 'mercure': provision http.handlers.mercure: "bolt://database/mercure.db?subscriptions=1": invalid transport: open /mercure.db: read-only file system
```
I've created a mount that should be writable. I'm not sure what I have not configured right.
How do I get mercure to work by allowing writable files? (I thought the mounted volumes are writable)
-
Official comment
Hi Dayton Outar,
Did you had a look on this multiple app blogpost?
I guess it could help as it is right your configuration.
On step 5 (Step 5: Configure mercure) you will find some useful info on how to configure it.
In the web.commands.start, you miss to specify which Caddyfile is loaded:
start: ./mercure run --config Caddyfile.platform_sh
Could you please share your Caddyfile and your mercure.sh scripts ?
And I can see that a source.root is missing:
source: # The path where the app code lives. Defaults to the directory of the .platform.app.yaml file. Useful for multi-app setups. root: mercure/.config
I didn't tested yet using a relationships from app to mercure to allow my Symfony application talk with mercure this way so i can't tell if it works.
-
Hi Dayton Outar,
Did you manage to make it work?
0
Please sign in to leave a comment.
Comments
2 comments