Giter VIP home page Giter VIP logo

laravel-octane-dockerfile's Introduction

Laravel Octane Dockerfile

A pretty configurable and production ready multi-stage Dockerfile for Laravel Octane powered web services and microservices.

The Docker configuration provides the following setup:

  • Debian Buster 10
  • PHP 8.0 and 8.1 with preconfigured JIT compiler and OPcache
  • Swoole extension with support of:
    • OpenSSL
    • HTTP/2
    • Native cURL hook for coroutines
    • mysqlnd
    • Asynchronous DNS

PHP extensions

And the following PHP extensions are included:

  • Swoole
  • OPcache
  • Redis
  • PCNTL
  • BCMath
  • RDKAFKA
  • INTL
  • pdo_mysql
  • pgsql
  • zip
  • cURL
  • GD
  • mbstring

Ports

Exposed ports of container:

Software Port
Swoole 9000

Usage

  1. Clone this repository: git clone [email protected]:exaco/laravel-octane-dockerfile.git
  2. Copy cloned directory content including deployment directory, Dockerfile and .dockerignore into your Octane powered Laravel project
  3. Change directory to your Laravel project
  4. Build your image: docker build -t <image-name>:<tag> .
  5. Up the container: docker run -p <port>:9000 --rm <image-name>:<tag>
  6. Visit http://localhost:<port>

Use in Laravel Sail

You can use this Dockerfile within Laravel Sail. Just change PHP container context to . and add <port>:9000 to ports in docker-compose.yml. You maybe need to remove WWWGROUP in args and WWWUSER in environment configuration in this file.

Configuration

There are something that you maybe want to configure:

  • Application request workers count in supervisord.conf
  • Max request count for request workers in supervisord.conf
  • The amount of workers available to process concurrent tasks in supervisord.conf
  • OPcache and JIT configurations in opcache.ini
  • PHP configurations in php.ini
  • ENTRYPOINT Bash script in entrypoint.sh
  • Set PHP_VERSION using the --build-arg option along with the build command
  • Set TZ (OS timezone) using the --build-arg option along with the build command

Recommended Swoole options in octane.php

// config/octane.php

return [
    'swoole' => [
            'options' => [
                'user' => 'octane',
                'group' => 'octane',
                'hook_flags' => SWOOLE_HOOK_NATIVE_CURL | SWOOLE_HOOK_TCP,
                'http_compression' => true,
                'http_compression_level' => 6, // 1 - 9
                'compression_min_length' => 20,
                'open_http2_protocol' => true,
                'open_cpu_affinity' => true,
                'tcp_fastopen' => true,
                'open_tcp_keepalive' => true,
                'open_tcp_nodelay' => true,
                'enable_reuse_port' => true,
            ]
        ]
];

Utilities

Also, some useful Bash functions and aliases are added in utilities.sh that maybe help.

Notes

  • Laravel Octane logs requests information only in the local environment.
  • Please be aware about .dockerignore content

Contributing

Thank you for considering contributing! If you find an issue, or have a better way to do something, feel free to open an issue, or a PR.

License

This repository is open-sourced software licensed under the MIT license.

laravel-octane-dockerfile's People

Contributors

smortexa avatar tiagodevweb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.