wip: franenphp in worker mode

This commit is contained in:
2025-05-23 20:38:22 -05:00
parent 34d9029b7c
commit 794189d70a
7 changed files with 135 additions and 54 deletions

View File

@@ -1,20 +1,26 @@
FROM trafex/php-nginx:3.9.0
FROM dunglas/frankenphp
USER root
RUN install-php-extensions \
pdo_mysql \
gd \
intl \
zip \
opcache
RUN apk add --no-cache \
php84-opcache \
php84-pdo_mysql \
php84-simplexml
#RUN apk add --no-cache \
# php84-opcache \
# php84-pdo_mysql \
# php84-simplexml
#
#USER nobody
#
#COPY --chmod=0775 ./bash/entrypoint.sh /usr/local/bin/
#COPY --chmod=0755 ./bash/nginx.conf /etc/nginx/conf.d/site.conf
#COPY --chmod=0755 ./docker/app/supervisord.conf /etc/supervisor/conf.d/async-queue.conf
USER nobody
COPY --chmod=0775 ./bash/entrypoint.sh /usr/local/bin/
COPY --chmod=0755 ./bash/nginx.conf /etc/nginx/conf.d/site.conf
HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD [ "php", "/var/www/bin/console", "startup:status" ]
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
WORKDIR /var/www
#HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD [ "php", "/var/www/bin/console", "startup:status" ]
#
#ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
#
#WORKDIR /var/www

View File

@@ -12,6 +12,21 @@ services:
- $PWD/bash/caddy:/etc/caddy
- $PWD/bash/certs:/etc/ssl
app:
build: .
restart: unless-stopped
environment:
SERVER_NAME: ":80"
FRANKENPHP_CONFIG: "worker /app/public/index.php"
CADDY_GLOBAL_OPTIONS: "auto_https off"
APP_RUNTIME: "Runtime\\FrankenPhpSymfony\\Runtime"
volumes:
- $PWD:/app
tty: true
depends_on:
database:
condition: service_healthy
redis:
image: redis:latest
volumes:
@@ -19,44 +34,33 @@ services:
command: redis-server --maxmemory 512MB
restart: unless-stopped
app:
build:
dockerfile: Dockerfile
context: .
ports:
- "8001:80"
volumes:
- ./:/var/www
depends_on:
database:
condition: service_healthy
worker:
build:
dockerfile: docker/Dockerfile.worker
context: .
volumes:
- ./:/app
- ./var/downloads/movies:/var/download/movies
- ./var/downloads/tvshows:/var/download/tvshows
command: -vvv --time-limit=3600
env_file:
- .env
depends_on:
app:
condition: service_healthy
# worker:
# build:
# dockerfile: docker/Dockerfile.worker
# context: .
# volumes:
# - ./:/app
# - ./var/downloads/movies:/var/download/movies
# - ./var/downloads/tvshows:/var/download/tvshows
# command: -vvv --time-limit=3600
# env_file:
# - .env
# depends_on:
# app:
# condition: service_healthy
scheduler:
build:
dockerfile: docker/Dockerfile.scheduler
context: .
volumes:
- ./:/var/www
- ./var/download:/var/download
command: -vv --time-limit=3600
depends_on:
app:
condition: service_healthy
# scheduler:
# build:
# dockerfile: docker/Dockerfile.scheduler
# context: .
# volumes:
# - ./:/var/www
# - ./var/download:/var/download
# command: -vv --time-limit=3600
# depends_on:
# app:
# condition: service_healthy
mercure:
image: dunglas/mercure

View File

@@ -22,6 +22,7 @@
"p3k/emoji-detector": "^1.2",
"php-tmdb/api": "^4.1",
"predis/predis": "^2.4",
"runtime/frankenphp-symfony": "^0.2.0",
"symfony/asset": "7.2.*",
"symfony/console": "7.2.*",
"symfony/doctrine-messenger": "7.2.*",

54
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "33f1579a34e7ada02bb4738a9b39f493",
"content-hash": "c4ad1f54b8dd44fb55097f631c945460",
"packages": [
{
"name": "1tomany/rich-bundle",
@@ -3300,6 +3300,58 @@
},
"time": "2021-10-29T13:26:27+00:00"
},
{
"name": "runtime/frankenphp-symfony",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/php-runtime/frankenphp-symfony.git",
"reference": "56822c3631d9522a3136a4c33082d006bdfe4bad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-runtime/frankenphp-symfony/zipball/56822c3631d9522a3136a4c33082d006bdfe4bad",
"reference": "56822c3631d9522a3136a4c33082d006bdfe4bad",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/runtime": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Runtime\\FrankenPhpSymfony\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kévin Dunglas",
"email": "kevin@dunglas.dev"
}
],
"description": "FrankenPHP runtime for Symfony",
"support": {
"issues": "https://github.com/php-runtime/frankenphp-symfony/issues",
"source": "https://github.com/php-runtime/frankenphp-symfony/tree/0.2.0"
},
"funding": [
{
"url": "https://github.com/nyholm",
"type": "github"
}
],
"time": "2023-12-12T12:06:11+00:00"
},
{
"name": "symfony/asset",
"version": "v7.2.0",

View File

@@ -5,6 +5,15 @@ framework:
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
download:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
use_notify: true
check_delayed_interval: 60000
retry_strategy:
max_retries: 1
multiplier: 1
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:

View File

@@ -4,4 +4,4 @@ RUN docker-php-ext-install pdo_mysql
COPY --chown=www-data:www-data . /app
ENTRYPOINT [ "php", "/app/bin/console", "messenger:consume", "async" ]
ENTRYPOINT [ "php", "/app/bin/console", "messenger:consume", "download" ]

View File

@@ -0,0 +1,9 @@
[program:messenger-consume]
command=php /var/www/bin/console messenger:consume async --time-limit=3600
user=nobody
numprocs=2
startsecs=0
autostart=true
autorestart=true
startretries=10
process_name=%(program_name)s_%(process_num)02d