From ff76665aed6bcb83355e78a3a9f4be5d6290c5b0 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 9 Jun 2024 18:00:48 +0200 Subject: [PATCH] Document how to use Octane with containers --- docs/deploy/docker.mdx | 8 ++++++++ docs/laravel/octane.mdx | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/deploy/docker.mdx b/docs/deploy/docker.mdx index e7ae64ba4..9ca6f9290 100644 --- a/docs/deploy/docker.mdx +++ b/docs/deploy/docker.mdx @@ -52,6 +52,14 @@ Bref offers the following base images: - `bref/php-xx-console:2`: to run PHP CLI commands - `bref/php-xx:2`: to run [PHP functions](../runtimes/function.mdx) + + The `CMD` instruction in `Dockerfile` must contain a valid JSON array. This is why you must escape any `\` character. This is important for PHP class names, for example when using Laravel Octane: + + ```dockerfile filename="Dockerfile" + CMD ["Bref\\LaravelBridge\\Http\\OctaneHandler"] + ``` + + ### Extra PHP extensions You can enable additional PHP extensions by pulling them from [Bref Extra Extensions](https://github.com/brefphp/extra-php-extensions): diff --git a/docs/laravel/octane.mdx b/docs/laravel/octane.mdx index 60517beb0..5c83008c5 100644 --- a/docs/laravel/octane.mdx +++ b/docs/laravel/octane.mdx @@ -1,4 +1,5 @@ import { NextSeo } from 'next-seo'; +import { Callout } from 'nextra/components'; @@ -23,6 +24,14 @@ Keep the following details in mind: - The process is kept alive between requests, but you still don't pay for time between requests. The execution model and cost model of AWS Lambda does not change (Lambda is frozen between requests). - `BREF_LOOP_MAX` specifies the number of HTTP requests handled before the PHP process is restarted (and the memory is cleared). + + If you deploy using [container images](../deploy/docker.mdx), you must escape the `\` characters in your `Dockerfile`: + + ```dockerfile filename="Dockerfile" + CMD ["Bref\\LaravelBridge\\Http\\OctaneHandler"] + ``` + + ## Persistent database connections You can keep database connections persistent across requests to make your application even faster. To do so, set the `OCTANE_PERSIST_DATABASE_SESSIONS` environment variable: