Skip to content

Commit

Permalink
Merge pull request #1821 from brefphp/document-octane-docker
Browse files Browse the repository at this point in the history
Document how to use Laravel Octane with containers
  • Loading branch information
mnapoli authored Jun 9, 2024
2 parents 1724132 + ff76665 commit 9223de2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/deploy/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<Callout type="warning">
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"]
```
</Callout>

### Extra PHP extensions

You can enable additional PHP extensions by pulling them from [Bref Extra Extensions](https://github.com/brefphp/extra-php-extensions):
Expand Down
9 changes: 9 additions & 0 deletions docs/laravel/octane.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextSeo } from 'next-seo';
import { Callout } from 'nextra/components';

<NextSeo description="Run Laravel with Octane on AWS Lambda using Bref." />

Expand All @@ -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).

<Callout>
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"]
```
</Callout>

## 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:
Expand Down

0 comments on commit 9223de2

Please sign in to comment.