mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-09 21:42:57 +00:00
use octane & frankenphp for docker image
This commit is contained in:
parent
76d4b9eba3
commit
fc9f0787a0
7 changed files with 249 additions and 50 deletions
|
|
@ -9,7 +9,6 @@
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/vendor
|
/vendor
|
||||||
.env
|
.env
|
||||||
.env.example
|
|
||||||
.env.backup
|
.env.backup
|
||||||
.env.production
|
.env.production
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
|
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -22,3 +22,7 @@ yarn-error.log
|
||||||
/.vscode
|
/.vscode
|
||||||
/.zed
|
/.zed
|
||||||
composer.lock
|
composer.lock
|
||||||
|
|
||||||
|
**/caddy
|
||||||
|
frankenphp
|
||||||
|
frankenphp-worker.php
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
"ext-gmp": "*",
|
"ext-gmp": "*",
|
||||||
"intervention/image-laravel": "^1.5",
|
"intervention/image-laravel": "^1.5",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^12.0",
|
||||||
|
"laravel/octane": "^2.9",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/tinker": "^2.10.1",
|
"laravel/tinker": "^2.10.1",
|
||||||
"league/flysystem": "^3.29",
|
"league/flysystem": "^3.29",
|
||||||
|
|
|
||||||
224
config/octane.php
Normal file
224
config/octane.php
Normal file
|
|
@ -0,0 +1,224 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Laravel\Octane\Contracts\OperationTerminated;
|
||||||
|
use Laravel\Octane\Events\RequestHandled;
|
||||||
|
use Laravel\Octane\Events\RequestReceived;
|
||||||
|
use Laravel\Octane\Events\RequestTerminated;
|
||||||
|
use Laravel\Octane\Events\TaskReceived;
|
||||||
|
use Laravel\Octane\Events\TaskTerminated;
|
||||||
|
use Laravel\Octane\Events\TickReceived;
|
||||||
|
use Laravel\Octane\Events\TickTerminated;
|
||||||
|
use Laravel\Octane\Events\WorkerErrorOccurred;
|
||||||
|
use Laravel\Octane\Events\WorkerStarting;
|
||||||
|
use Laravel\Octane\Events\WorkerStopping;
|
||||||
|
use Laravel\Octane\Listeners\CloseMonologHandlers;
|
||||||
|
use Laravel\Octane\Listeners\CollectGarbage;
|
||||||
|
use Laravel\Octane\Listeners\DisconnectFromDatabases;
|
||||||
|
use Laravel\Octane\Listeners\EnsureUploadedFilesAreValid;
|
||||||
|
use Laravel\Octane\Listeners\EnsureUploadedFilesCanBeMoved;
|
||||||
|
use Laravel\Octane\Listeners\FlushOnce;
|
||||||
|
use Laravel\Octane\Listeners\FlushTemporaryContainerInstances;
|
||||||
|
use Laravel\Octane\Listeners\FlushUploadedFiles;
|
||||||
|
use Laravel\Octane\Listeners\ReportException;
|
||||||
|
use Laravel\Octane\Listeners\StopWorkerIfNecessary;
|
||||||
|
use Laravel\Octane\Octane;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Octane Server
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the default "server" that will be used by Octane
|
||||||
|
| when starting, restarting, or stopping your server via the CLI. You
|
||||||
|
| are free to change this to the supported server of your choosing.
|
||||||
|
|
|
||||||
|
| Supported: "roadrunner", "swoole", "frankenphp"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'server' => env('OCTANE_SERVER', 'frankenphp'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Force HTTPS
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When this configuration value is set to "true", Octane will inform the
|
||||||
|
| framework that all absolute links must be generated using the HTTPS
|
||||||
|
| protocol. Otherwise your links may be generated using plain HTTP.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'https' => env('OCTANE_HTTPS', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Octane Listeners
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| All of the event listeners for Octane's events are defined below. These
|
||||||
|
| listeners are responsible for resetting your application's state for
|
||||||
|
| the next request. You may even add your own listeners to the list.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'listeners' => [
|
||||||
|
WorkerStarting::class => [
|
||||||
|
EnsureUploadedFilesAreValid::class,
|
||||||
|
EnsureUploadedFilesCanBeMoved::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
RequestReceived::class => [
|
||||||
|
...Octane::prepareApplicationForNextOperation(),
|
||||||
|
...Octane::prepareApplicationForNextRequest(),
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
RequestHandled::class => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
RequestTerminated::class => [
|
||||||
|
// FlushUploadedFiles::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
TaskReceived::class => [
|
||||||
|
...Octane::prepareApplicationForNextOperation(),
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
TaskTerminated::class => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
TickReceived::class => [
|
||||||
|
...Octane::prepareApplicationForNextOperation(),
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
TickTerminated::class => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
OperationTerminated::class => [
|
||||||
|
FlushOnce::class,
|
||||||
|
FlushTemporaryContainerInstances::class,
|
||||||
|
// DisconnectFromDatabases::class,
|
||||||
|
// CollectGarbage::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
WorkerErrorOccurred::class => [
|
||||||
|
ReportException::class,
|
||||||
|
StopWorkerIfNecessary::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
WorkerStopping::class => [
|
||||||
|
CloseMonologHandlers::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Warm / Flush Bindings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The bindings listed below will either be pre-warmed when a worker boots
|
||||||
|
| or they will be flushed before every new request. Flushing a binding
|
||||||
|
| will force the container to resolve that binding again when asked.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'warm' => [
|
||||||
|
...Octane::defaultServicesToWarm(),
|
||||||
|
],
|
||||||
|
|
||||||
|
'flush' => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Octane Swoole Tables
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While using Swoole, you may define additional tables as required by the
|
||||||
|
| application. These tables can be used to store data that needs to be
|
||||||
|
| quickly accessed by other workers on the particular Swoole server.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'tables' => [
|
||||||
|
'example:1000' => [
|
||||||
|
'name' => 'string:1000',
|
||||||
|
'votes' => 'int',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Octane Swoole Cache Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While using Swoole, you may leverage the Octane cache, which is powered
|
||||||
|
| by a Swoole table. You may set the maximum number of rows as well as
|
||||||
|
| the number of bytes per row using the configuration options below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
'rows' => 1000,
|
||||||
|
'bytes' => 10000,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| File Watching
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following list of files and directories will be watched when using
|
||||||
|
| the --watch option offered by Octane. If any of the directories and
|
||||||
|
| files are changed, Octane will automatically reload your workers.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'watch' => [
|
||||||
|
'app',
|
||||||
|
'bootstrap',
|
||||||
|
'config/**/*.php',
|
||||||
|
'database/**/*.php',
|
||||||
|
'public/**/*.php',
|
||||||
|
'resources/**/*.php',
|
||||||
|
'routes',
|
||||||
|
'composer.lock',
|
||||||
|
'.env',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Garbage Collection Threshold
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When executing long-lived PHP scripts such as Octane, memory can build
|
||||||
|
| up before being cleared by PHP. You can force Octane to run garbage
|
||||||
|
| collection if your application consumes this amount of megabytes.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'garbage' => 50,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maximum Execution Time
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following setting configures the maximum execution time for requests
|
||||||
|
| being handled by Octane. You may set this value to 0 to indicate that
|
||||||
|
| there isn't a specific time limit on Octane request execution time.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'max_execution_time' => 30,
|
||||||
|
|
||||||
|
];
|
||||||
|
|
@ -1,28 +1,23 @@
|
||||||
# Stage 1: Build
|
FROM dunglas/frankenphp
|
||||||
FROM joseluisq/php-fpm:8.4 AS build
|
|
||||||
|
|
||||||
RUN apk add --no-cache nodejs npm
|
# Copy php.ini
|
||||||
|
COPY ./deploy/php.ini $PHP_INI_DIR/php.ini
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
RUN apt update -y && apt install -y git nodejs npm
|
||||||
COPY --chown=www-data:www-data . .
|
COPY --from=composer:lts /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
RUN chmod -R 775 /var/www/html/storage \
|
RUN install-php-extensions \
|
||||||
&& chmod -R 775 /var/www/html/bootstrap/cache
|
gd \
|
||||||
|
opcache \
|
||||||
|
redis \
|
||||||
|
mongodb
|
||||||
|
|
||||||
RUN composer install --no-dev --prefer-dist \
|
COPY . /app
|
||||||
&& npm install \
|
|
||||||
&& npm run build
|
|
||||||
|
|
||||||
RUN chown -R www-data:www-data /var/www/html/vendor \
|
RUN cp .env.example .env
|
||||||
&& chmod -R 775 /var/www/html/vendor
|
RUN sed -i'' -e 's/^APP_ENV=.*/APP_ENV=production/' -e 's/^APP_DEBUG=.*/APP_DEBUG=false/' .env
|
||||||
|
|
||||||
# Stage 2: Deploy
|
RUN composer install --ignore-platform-reqs --no-dev -a
|
||||||
FROM joseluisq/php-fpm:8.4
|
RUN npm install && npm run build
|
||||||
|
|
||||||
COPY --from=build /var/www/html /var/www/html
|
ENTRYPOINT ["php", "artisan", "octane:frankenphp", "--host=0.0.0.0"]
|
||||||
WORKDIR /var/www/html
|
|
||||||
|
|
||||||
VOLUME ["/var/www/html/storage/app"]
|
|
||||||
|
|
||||||
EXPOSE 9000
|
|
||||||
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=9000", "--tries=1"]
|
|
||||||
|
|
|
||||||
|
|
@ -7,35 +7,9 @@ services:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: ./deploy/Dockerfile
|
dockerfile: ./deploy/Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ../storage/app:/var/www/html/storage/app
|
- .:/app
|
||||||
environment:
|
|
||||||
APP_NAME: ${APP_NAME}
|
|
||||||
APP_ENV: ${APP_ENV}
|
|
||||||
APP_DEBUG: ${APP_DEBUG}
|
|
||||||
APP_KEY: ${APP_KEY}
|
|
||||||
APP_URL: ${APP_URL}
|
|
||||||
DB_CONNECTION: ${DB_CONNECTION}
|
|
||||||
DB_HOST: ${DB_HOST}
|
|
||||||
DB_NAME: ${DB_NAME}
|
|
||||||
AUTHENTIK_BASE_URL: ${AUTHENTIK_BASE_URL}
|
|
||||||
AUTHENTIK_CLIENT_ID: ${AUTHENTIK_CLIENT_ID}
|
|
||||||
AUTHENTIK_CLIENT_SECRET: ${AUTHENTIK_CLIENT_SECRET}
|
|
||||||
AUTHENTIK_REDIRECT_URI: ${APP_URL}/auth/callback
|
|
||||||
SESSION_DRIVER: ${SESSION_DRIVER}
|
|
||||||
FILESYSTEM_DISK: ${FILESYSTEM_DISK}
|
|
||||||
CACHE_STORE: ${CACHE_STORE}
|
|
||||||
REDIS_CLIENT: ${REDIS_CLIENT}
|
|
||||||
REDIS_HOST: ${REDIS_HOST}
|
|
||||||
MAIL_MAILER: ${MAIL_MAILER}
|
|
||||||
MAIL_SCHEME: ${MAIL_SCHEME}
|
|
||||||
MAIL_HOST: ${MAIL_HOST}
|
|
||||||
MAIL_PORT: ${MAIL_PORT}
|
|
||||||
MAIL_USERNAME: ${MAIL_USERNAME}
|
|
||||||
MAIL_PASSWORD: ${MAIL_PASSWORD}
|
|
||||||
MAIL_FROM_ADDRESS: ${MAIL_FROM_ADDRESS}
|
|
||||||
MAIL_FROM_NAME: ${MAIL_FROM_NAME}
|
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- "8000:8000"
|
||||||
networks:
|
networks:
|
||||||
- nyaabooru-internal
|
- nyaabooru-internal
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
||||||
2
deploy/php.ini
Normal file
2
deploy/php.ini
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
upload_max_filesize = 64M
|
||||||
|
post_max_filesize = 72M
|
||||||
Loading…
Add table
Add a link
Reference in a new issue