A very basic bare bones, multi-stage Dockerfile for Laravel Octane powered web services and microservices.
The Docker configuration provides the following setup:
- PHP 8.0 and 8.1 official DebianBuster-based images
- Preconfigured JIT compiler and OPcache
And the following PHP extensions are included:
- OpenSwoole/Swoole with support of OpenSSL, HTTP/2, Native cURL hook for coroutines,
mysqlnd
and asynchronous DNS. - OPcache
- Redis
- PCNTL
- BCMath
- INTL
- pdo_mysql
- zip
- cURL
- GD
- mbstring
Clone this repository:
git clone [email protected]:heyjordn/laravel-octane-dockerfile-basic.git
Copy cloned directory content including deployment
directory, Dockerfile
and .dockerignore
into your Octane powered Laravel project
Change directory to your Laravel project
Build your image:
docker build -t <image-name>:<tag> .
Start the container:
docker run -p <port>:9000 --rm <image-name>:<tag>
There are something that you maybe want to configure:
- Swoole HTTP server config in
supervisord.app.conf
- OPcache and JIT configurations in
opcache.ini
- PHP configurations in
php.ini
ENTRYPOINT
Bash script inentrypoint.sh
option along with the build command
// config/octane.php
return [
'swoole' => [
'options' => [
'http_compression' => true,
'http_compression_level' => 6, // 1 - 9
'compression_min_length' => 20,
'open_http2_protocol' => true
]
]
];
- Reduce build time by removing extra extensions/deps.
This repository is open-sourced software licensed under the MIT license.
Special thanks to exaco and laravel-octane-dockerfile for the head start, this is essentially that dockerfile without horizon, scheduler and some extra extensions. Check out laravel-octane-dockerfile to see the production ready file.