Skip to content

[php] Laravel with RoadRunner #10041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frameworks/PHP/laravel/config/octane.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'octane' => [
'max_requests' => 10000, // Reload workers after requests
],
];

32 changes: 22 additions & 10 deletions frameworks/PHP/laravel/deploy/roadrunner/.rr.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
# see https://roadrunner.dev/docs/intro-config
# see https://docs.roadrunner.dev/docs/general/config
# https://github.com/roadrunner-server/roadrunner/blob/master/.rr.yaml

version: "3"
#https://github.com/roadrunner-server/roadrunner/blob/master/.rr.yaml

server:
command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///usr/local/var/run/rr-rpc.sock"
relay: "unix:///usr/local/var/run/rr-rpc.sock"
logs:
mode: production
level: error
http:
address: 0.0.0.0:8080
middleware: ["headers"]
pool:
#max_jobs: 64 # feel free to change this
num_workers: 0
max_jobs: 0
supervisor:
exec_ttl: 60s
headers:
response:
Server: "RoadRunner"
middleware: ["headers"]

server:
command: "php /laravel/vendor/bin/roadrunner-worker"
#command: "php /laravel/vendor/bin/roadrunner-worker start --relay-dsn unix:///usr/local/var/run/rr-rpc.sock"
#relay: "unix:///usr/local/var/run/rr-rpc.sock"

env:
- APP_ENV: production
- APP_BASE_PATH: "/laravel"
- LARAVEL_OCTANE: "1"

rpc:
listen: tcp://127.0.0.1:6001

logs:
mode: production
level: error
output: stdout
#encoding: json
45 changes: 0 additions & 45 deletions frameworks/PHP/laravel/deploy/roadrunner/composer.json

This file was deleted.

26 changes: 11 additions & 15 deletions frameworks/PHP/laravel/laravel-roadrunner.dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM php:8.3-cli
FROM php:8.4-cli

RUN docker-php-ext-install pdo_mysql pcntl opcache sockets > /dev/null

RUN echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
#RUN echo "opcache.jit=1205" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
#RUN echo "opcache.jit_buffer_size=128M" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
RUN echo "opcache.jit=1205" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
RUN echo "opcache.jit_buffer_size=128M" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini

WORKDIR /laravel
COPY --link . .
Expand All @@ -18,21 +18,17 @@ RUN mkdir -p bootstrap/cache \
RUN apt-get update > /dev/null && \
apt-get install -yqq curl unzip > /dev/null

COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer
RUN pecl install protobuf > /dev/null && echo "extension=protobuf.so" > /usr/local/etc/php/conf.d/protobuf.ini

COPY --link deploy/roadrunner/composer.json .
COPY --link deploy/roadrunner/.rr.yaml .
COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer

RUN composer install -a --no-dev --quiet
RUN composer require laravel/octane --update-no-dev --no-scripts --quiet
RUN php artisan octane:install --server="roadrunner"
RUN php artisan optimize

# install roadrunner
COPY --from=ghcr.io/roadrunner-server/roadrunner:2023.3 --link /usr/bin/rr /usr/local/bin/rr

RUN php artisan vendor:publish --provider='Spiral\RoadRunnerLaravel\ServiceProvider' --tag=config
RUN rr -v

EXPOSE 8080

# CMD bash
CMD rr serve -c .rr.yaml
# https://artisan.page/12.x/
#ENTRYPOINT ["php", "artisan", "octane:roadrunner", "--host=0.0.0.0", "--port=8080", "--workers=auto", "--max-requests=10000", "--rr-config=/laravel/deploy/roadrunner/.rr.yaml"]
ENTRYPOINT ["/laravel/rr", "serve", "-c", "/laravel/deploy/roadrunner/.rr.yaml"]