Skip to content

Commit 9bb0b17

Browse files
authored
Merge pull request #660 from YanGusik/symfony-spawn-franken
Add symfony-spawn-franken
2 parents 61cc1a1 + fd707d4 commit 9bb0b17

15 files changed

Lines changed: 399 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
APP_ENV=prod
2+
APP_DEBUG=0
3+
APP_SECRET=benchmark_httparena_secret
4+
DATABASE_URL=pgsql://bench:bench@localhost:5432/benchmark
5+
DEFAULT_URI=http://localhost
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
admin off
3+
auto_https off
4+
frankenphp
5+
}
6+
7+
:8080 {
8+
encode br gzip
9+
root * /app/public
10+
php_server {
11+
index off
12+
file_server off
13+
worker {
14+
file /app/worker.php
15+
num {$WORKERS:0}
16+
async
17+
match /*
18+
}
19+
}
20+
}
21+
22+
:8443 {
23+
tls /certs/server.crt /certs/server.key
24+
root * /app/public
25+
php_server {
26+
index off
27+
file_server off
28+
worker {
29+
file /app/worker.php
30+
num {$WORKERS:0}
31+
async
32+
match /*
33+
}
34+
}
35+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM trueasync/php-true-async:latest-frankenphp
2+
3+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
4+
5+
WORKDIR /app
6+
7+
COPY composer.json ./
8+
9+
RUN APP_ENV=prod composer install --no-dev --optimize-autoloader --no-scripts --no-interaction
10+
11+
COPY . .
12+
13+
RUN APP_ENV=prod APP_DEBUG=0 APP_SECRET=benchmark \
14+
DATABASE_URL=pgsql://bench:bench@localhost:5432/benchmark \
15+
DEFAULT_URI=http://localhost \
16+
php bin/console cache:warmup
17+
18+
RUN echo '\
19+
opcache.enable=1\n\
20+
opcache.enable_cli=1\n\
21+
opcache.jit=1255\n\
22+
opcache.jit_buffer_size=128M\n\
23+
opcache.memory_consumption=256\n\
24+
opcache.max_accelerated_files=10000\n\
25+
opcache.validate_timestamps=0\n\
26+
memory_limit=2048M\n\
27+
' >> /etc/php.d/99-benchmark.ini
28+
29+
ENV GODEBUG=cgocheck=0
30+
ENV GOGC=1000
31+
ENV APP_ENV=prod
32+
ENV APP_DEBUG=0
33+
ENV APP_SECRET=benchmark
34+
ENV DATABASE_URL=pgsql://bench:bench@localhost:5432/benchmark
35+
ENV DEFAULT_URI=http://localhost
36+
37+
COPY Caddyfile /etc/caddy/Caddyfile
38+
39+
EXPOSE 8080 8443/tcp 8443/udp
40+
41+
CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"type": "project",
3+
"license": "MIT",
4+
"minimum-stability": "dev",
5+
"prefer-stable": true,
6+
"require": {
7+
"php": ">=8.6",
8+
"ext-ctype": "*",
9+
"ext-iconv": "*",
10+
"ext-pcntl": "*",
11+
"ext-pdo": "*",
12+
"doctrine/dbal": "^4.4",
13+
"doctrine/doctrine-bundle": "^2.18",
14+
"symfony/console": "7.4.*",
15+
"symfony/dotenv": "7.4.*",
16+
"symfony/flex": "^2",
17+
"symfony/framework-bundle": "7.4.*",
18+
"symfony/runtime": "7.4.*",
19+
"symfony/yaml": "7.4.*",
20+
"yangusik/symfony-spawn": "*"
21+
},
22+
"config": {
23+
"allow-plugins": {
24+
"php-http/discovery": true,
25+
"symfony/flex": true,
26+
"symfony/runtime": true
27+
},
28+
"sort-packages": true
29+
},
30+
"autoload": {
31+
"psr-4": {
32+
"App\\": "src/"
33+
}
34+
},
35+
"replace": {
36+
"symfony/polyfill-ctype": "*",
37+
"symfony/polyfill-iconv": "*",
38+
"symfony/polyfill-php72": "*",
39+
"symfony/polyfill-php73": "*",
40+
"symfony/polyfill-php74": "*",
41+
"symfony/polyfill-php80": "*",
42+
"symfony/polyfill-php81": "*",
43+
"symfony/polyfill-php82": "*"
44+
},
45+
"scripts": {
46+
"auto-scripts": {
47+
"cache:clear": "symfony-cmd"
48+
},
49+
"post-install-cmd": [
50+
"@auto-scripts"
51+
],
52+
"post-update-cmd": [
53+
"@auto-scripts"
54+
]
55+
},
56+
"conflict": {
57+
"symfony/symfony": "*"
58+
},
59+
"extra": {
60+
"symfony": {
61+
"allow-contrib": false,
62+
"require": "7.4.*"
63+
}
64+
}
65+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
5+
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
6+
Spawn\Symfony\TrueAsyncBundle::class => ['all' => true],
7+
];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
doctrine:
2+
dbal:
3+
driver_class: Spawn\Symfony\Database\TrueAsyncPgsqlDriver
4+
url: '%env(DATABASE_URL)%'
5+
server_version: '17'
6+
use_savepoints: true
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
framework:
2+
secret: '%env(APP_SECRET)%'
3+
http_method_override: false
4+
handle_all_throwables: true
5+
php_errors:
6+
log: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
true_async:
2+
db_pool:
3+
enabled: true
4+
min: 4
5+
max: 64
6+
healthcheck_interval: 30
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
controllers:
2+
resource:
3+
path: ../src/Controller/
4+
namespace: App\Controller
5+
type: attribute
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
6+
App\:
7+
resource: '../src/'

0 commit comments

Comments
 (0)