Skip to content

Commit a3961b8

Browse files
committed
merge in fifo demo
2 parents 8804c9d + f327f1a commit a3961b8

File tree

66 files changed

+4760
-441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4760
-441
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ COPY . /app
2828

2929
WORKDIR /app/examples
3030

31-
RUN composer install --no-interaction --prefer-dist --ignore-platform-reqs
31+
#RUN composer install --no-interaction --prefer-dist --ignore-platform-reqs
3232

3333
COPY --from=node-build /app/examples/public/build ./public/build
3434
COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
3535

36+
COPY docker-entrypoint.sh /usr/local/bin/
37+
ENTRYPOINT ["docker-entrypoint.sh"]
3638
CMD ["rr", "serve"]

compose.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
gateway:
33
image: caddy:2-alpine
4+
restart: unless-stopped
45
volumes:
56
- ./examples/Caddyfile:/etc/caddy/Caddyfile:ro
67
ports:
@@ -14,13 +15,16 @@ services:
1415
build:
1516
context: .
1617
dockerfile: Dockerfile
18+
restart: unless-stopped
1719
environment:
1820
REDIS_HOST: redis
1921
REDIS_PORT: 6379
2022
MERCURE_HUB_URL: http://mercure/.well-known/mercure
2123
MERCURE_JWT_SECRET: ${MERCURE_JWT_SECRET:-airlock-mercure-secret-32chars-minimum}
2224
MERCURE_PUBLIC_URL: ${MERCURE_PUBLIC_URL:-http://localhost/.well-known/mercure}
2325
VITE_DEV: ${VITE_DEV:-false}
26+
ports:
27+
- "2112:2112"
2428
volumes:
2529
- ./examples:/app/examples
2630
- ./src:/app/src
@@ -35,6 +39,7 @@ services:
3539
context: .
3640
dockerfile: Dockerfile
3741
command: supervisord -n -c /app/examples/supervisord.conf
42+
restart: unless-stopped
3843
environment:
3944
REDIS_HOST: redis
4045
REDIS_PORT: 6379
@@ -51,6 +56,7 @@ services:
5156

5257
mercure:
5358
image: dunglas/mercure
59+
restart: unless-stopped
5460
environment:
5561
SERVER_NAME: :80
5662
MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_SECRET:-airlock-mercure-secret-32chars-minimum}
@@ -62,15 +68,32 @@ services:
6268

6369
centrifugo:
6470
image: centrifugo/centrifugo:v5
71+
restart: unless-stopped
6572
volumes:
6673
- ./examples/config.json:/centrifugo/config.json:ro
6774
command: centrifugo --config config.json
6875

6976
redis:
7077
image: redis:8.4.0
78+
restart: unless-stopped
7179
ports:
7280
- "6379:6379"
7381

82+
prometheus:
83+
image: prom/prometheus:v3.5.1
84+
restart: unless-stopped
85+
volumes:
86+
- ./prometheus/:/etc/prometheus/
87+
- prometheus_data:/prometheus
88+
command:
89+
- '--config.file=/etc/prometheus/prometheus.yml'
90+
- '--storage.tsdb.path=/prometheus'
91+
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
92+
- '--web.console.templates=/usr/share/prometheus/consoles'
93+
ports:
94+
- "9090:9090"
95+
96+
7497
e2e:
7598
build:
7699
context: e2e
@@ -86,3 +109,6 @@ services:
86109
- gateway
87110
command: >
88111
sh -c "npm install && npx playwright test"
112+
113+
volumes:
114+
prometheus_data:

docker-entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Re-generate autoloader so volume-mounted source changes are picked up.
5+
# Without this, the classmap baked at build time goes stale when ./src or
6+
# ./examples are mounted over the image layer at runtime.
7+
composer dump-autoload --no-interaction --quiet 2>/dev/null || true
8+
php app.php cache:clean || true
9+
10+
exec "$@"

examples/.rr.yaml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,55 @@
11
version: '3'
2+
23
rpc:
34
listen: 'tcp://127.0.0.1:6001'
5+
46
http:
57
address: '0.0.0.0:8080'
68
middleware:
79
- gzip
810
- static
11+
- http_metrics
912
static:
1013
dir: public
1114
forbid:
1215
- .php
1316
- .htaccess
1417
pool:
15-
debug: false
18+
debug: true
1619
num_workers: 4
1720
supervisor:
1821
max_worker_memory: 100
22+
1923
server:
2024
command: 'php app.php'
2125
relay: pipes
26+
2227
kv:
2328
local:
2429
driver: memory
2530
config:
2631
interval: 60
27-
jobs:
28-
pool:
29-
num_workers: 2
30-
max_worker_memory: 100
31-
consume: { }
32+
33+
metrics:
34+
address: 0.0.0.0:2112
35+
36+
collect:
37+
airlock_entries_total:
38+
type: counter
39+
labels: [ "airlock", "result" ]
40+
41+
airlock_leaves_total:
42+
type: counter
43+
labels: [ "airlock" ]
44+
45+
airlock_releases_total:
46+
type: counter
47+
labels: [ "airlock" ]
48+
49+
airlock_refreshes_total:
50+
type: counter
51+
labels: [ "airlock", "result" ]
52+
53+
airlock_entry_duration_seconds:
54+
type: histogram
55+
labels: [ "airlock" ]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Application\Bootloader;
6+
7+
use Clegginabox\Airlock\Bridge\Symfony\Mercure\SymfonyMercureHubFactory;
8+
use Spiral\Boot\Bootloader\Bootloader;
9+
use Spiral\Boot\EnvironmentInterface;
10+
use Symfony\Component\Mercure\HubInterface;
11+
12+
final class MercureBootloader extends Bootloader
13+
{
14+
protected const SINGLETONS = [
15+
HubInterface::class => [self::class, 'createHub'],
16+
];
17+
18+
private function createHub(EnvironmentInterface $env): HubInterface
19+
{
20+
$hubUrl = (string) $env->get('MERCURE_HUB_URL', 'http://localhost/.well-known/mercure');
21+
$jwtSecret = (string) $env->get('MERCURE_JWT_SECRET', 'airlock-mercure-secret-32chars-minimum');
22+
23+
return SymfonyMercureHubFactory::create($hubUrl, $jwtSecret);
24+
}
25+
}

examples/app/src/Application/Kernel.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@
1111
use Spiral\Cache\Bootloader\CacheBootloader;
1212
use Spiral\Debug\Bootloader\DumperBootloader;
1313
use Spiral\DotEnv\Bootloader\DotenvBootloader;
14+
use Spiral\Events\Bootloader\EventsBootloader;
1415
use Spiral\League\Event\Bootloader\EventBootloader;
1516
use Spiral\Monolog\Bootloader\MonologBootloader;
1617
use Spiral\Nyholm\Bootloader\NyholmBootloader;
1718
use Spiral\OpenTelemetry\Bootloader\OpenTelemetryBootloader;
1819
use Spiral\Prototype\Bootloader\PrototypeBootloader;
1920
use Spiral\Queue\Bootloader\QueueBootloader;
2021
use Spiral\RoadRunnerBridge\Bootloader as RoadRunnerBridge;
22+
use Spiral\RoadRunnerBridge\Bootloader\MetricsBootloader;
2123
use Spiral\Scaffolder\Bootloader\ScaffolderBootloader;
24+
use Spiral\Sentry\Bootloader\SentryReporterBootloader;
2225
use Spiral\Tokenizer\Bootloader\TokenizerListenerBootloader;
2326
use Spiral\Twig\Bootloader\TwigBootloader;
2427
use Spiral\Views\Bootloader\ViewsBootloader;
28+
use Spiral\YiiErrorHandler\Bootloader\YiiErrorHandlerBootloader;
2529

2630
/**
2731
* @psalm-suppress ClassMustBeFinal
@@ -46,6 +50,7 @@ public function defineBootloaders(): array
4650
return [
4751
// Logging and exceptions handling
4852
MonologBootloader::class,
53+
YiiErrorHandlerBootloader::class,
4954
Bootloader\ExceptionHandlerBootloader::class,
5055

5156
// Application specific logs
@@ -81,11 +86,17 @@ public function defineBootloaders(): array
8186
// OTEL
8287
OpenTelemetryBootloader::class,
8388

89+
// Sentry
90+
SentryReporterBootloader::class,
91+
92+
// Metrics
93+
MetricsBootloader::class,
94+
8495
// Queue
8596
QueueBootloader::class,
8697

8798
// Events
88-
//EventsBootloader::class,
99+
EventsBootloader::class,
89100
EventBootloader::class,
90101

91102
// Cache
@@ -115,6 +126,7 @@ public function defineAppBootloaders(): array
115126
{
116127
return [
117128
Bootloader\RedisBootloader::class,
129+
Bootloader\MercureBootloader::class,
118130
Bootloader\ViteBootloader::class,
119131

120132
// Application domain

0 commit comments

Comments
 (0)