Production ready Dockerfile for Octane powered Laravelish web services and microservices

Overview

Laravel Octane Dockerfile

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

The Docker configuration provides the following setup:

  • Debian Buster 10
  • PHP 8.0
  • Swoole Server

PHP extensions

And the following PHP extensions are included:

  • Swoole
  • OPcache
  • Redis
  • PCNTL
  • BCMATH
  • RDKAFKA
  • INTL
  • pdo_mysql
  • MySQL Client
  • 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 into your Octane powered Laravel project

  3. Change directory to your Laravel project

  4. Build your image:

    docker build -t <container-name>:<tag> .

  5. Up the container:

    docker run -p <port>:9000 --rm <container-name>:<tag>

  6. Visit http://localhost:<port>

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 OS timezone using the --build-arg option along with the build command

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.

Comments
  • {BUG} /usr/bin/env: 'bash\r': No such file or directory

    {BUG} /usr/bin/env: 'bash\r': No such file or directory

    After building the docker image and running it. docker run -p 8000:9000 --rm panja:latest it's giving an error /usr/bin/env: 'bash\r': No such file or directory

    image

    opened by 4183r 11
  • Problem running container

    Problem running container

    Complaining about Class "Facade\Ignition\IgnitionServiceProvider" not found when running the container, I realized that this is a require-dev dependency and that --no-scripts doesn't enable @php artisan package:discover --ansi if you move for require dependencies, do you have any solution?

    opened by tiagodevweb 4
  • Why you using supervisor?

    Why you using supervisor?

    Using supervisor in container as main process is bad practice. It req additional resources, it useless mediator via our app. Why you not used only octane?

    question 
    opened by Dezinger 3
  • ./deployment/octane/entrypoint.sh: no such file or directory: unknown

    ./deployment/octane/entrypoint.sh: no such file or directory: unknown

     => naming to docker.io/library/accounts_lumen                                                                  0.0s
    Starting accounts ... error
    
    ERROR: for accounts  Cannot start service lumen: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./deployment/octane/entrypoint.sh": stat ./deployment/octane/entrypoint.sh: no such file or directory: unknown
    
    ERROR: for lumen  Cannot start service lumen: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./deployment/octane/entrypoint.sh": stat ./deployment/octane/entrypoint.sh: no such file or directory: unknown
    ERROR: Encountered errors while bringing up the project.
    

    The file exists in the docker folder still facing any issue My Folder structure is as below. accounts\docker\deployment\octane\entrypoint.sh

    The below step works. If I rename entrypoint.sh file then it shows file not found in this step. => CACHED [stage-1 22/23] RUN chmod +x ./deployment/octane/entrypoint.sh

    opened by Dasinfomedia2 3
  • Can't change `max_execution_time` value

    Can't change `max_execution_time` value

    Hi, First of all thanks for all your work. I'm facing a little issue, I don't know if it's expected or not : I can't change the value of max_execution_time in the php configuration. I made the change in deployment/octane/php.ini file, but when the container is running and I run phpinfo(), I see max_execution_time is set to 0. When running PHP from the command line the default setting is 0. From : https://www.php.net/manual/en/info.configuration.php#ini.max-execution-time I'm able to change other PHP configuration like default_socket_timeout for example.

    Also a last thing, not really related to your Dockerfile : When we run an artisan command, the boot and register methods of AppServiceProvider are triggered. Is it excepted ?

    Thanks for the help !

    question 
    opened by Cemoche 2
  • Permission denied on laravel.log during start

    Permission denied on laravel.log during start

    I have a fresh laravel installation and added the files from this repo according to the instructions. The app won't start when running docker run.

    2022-09-13 08:03:55,959 INFO spawned: 'octane_00' with pid 69
    
    In StreamHandler.php line 146:
    
      The stream or file "/var/www/html/storage/logs/laravel.log" could not be op
      ened in append mode: Failed to open stream: Permission denied
      The exception occurred while attempting to log: The stream or file "/var/ww
      w/html/storage/logs/laravel.log" could not be opened in append mode: Failed
       to open stream: Permission denied
      The exception occurred while attempting to log: There are no commands defin
      ed in the "octane" namespace.
      Context: {"exception":{}}
      Context: {"exception":{}}
    

    How to fix this? Is this a bug?

    UPDATE: Nevermind, had to add octane via composer before and install it according to the laravel docs. Maybe add this requirement to the docs?

    opened by ludgerey 1
  • Running as non root

    Running as non root

    If you want to switch the user to another user like octane in the Dockerfile

    USER 1000:1000
    

    Then this fails, is there away to run the php() function and the exec supervisord commands in entrypoint.sh as non root?

    opened by georgefromohio 1
  • during install stoped

    during install stoped

    in first docker build -t sampledoc:test . enable sockets supports? [no] : enable json support? [no] : enable postgres support? [no] : Even if I say no or yes, nothing happens

    opened by vahidalvandi 1
  • AWS Fargate is replacing environment variables (AWS_*)

    AWS Fargate is replacing environment variables (AWS_*)

    The issue comes when we're running the docker image in ECS. it's replacing AWS_DEFAULT_REGION from eu-central-1 to eu-west-2

    image

    With FPM it loads the ENV normally image

    our .env file image

    So we're trying to access the S3 bucket which is hosted in a eu-central-1 region. and we're running ECS in eu-west-2

    needs more info 
    opened by 4183r 1
  • Running container for development

    Running container for development

    Great work , Can you tell me how can i run this container for development i added --watch flag to supervisor command and it throws this error :

    ==================Error==================
    Error: Cannot find module 'chokidar'
    
    Require stack:
    
    - /var/www/html/api/laravel/vendor/laravel/octane/bin/file-watcher.js
    
        at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    
        at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    
        at Module.require (node:internal/modules/cjs/loader:1005:19)
    
        at require (node:internal/modules/cjs/helpers:102:18)
    
        at Object.<anonymous> (/var/www/html/api/laravel/vendor/laravel/octane/bin/file-watcher.js:1:18)
    
        at Module._compile (node:internal/modules/cjs/loader:1103:14)
    
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    
        at Module.load (node:internal/modules/cjs/loader:981:32)
    
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
    
      code: 'MODULE_NOT_FOUND',
    
      requireStack: [
    
        '/var/www/html/api/laravel/vendor/laravel/octane/bin/file-watcher.js'
    
      ]
    
    }
    
    ==================supervisord==================
    [program:octane]
    process_name=%(program_name)s_%(process_num)02d
    command=php /var/www/html/api/laravel/artisan octane:start --server=swoole --host=0.0.0.0 --port=9000 --workers=auto --task-workers=auto --max-requests=500 --watch
    

    I added this code to Dockerfile but it doesnt work

    =====================Dockerfile==================
    =======================================
    ========= NODE  for octane --watch ==================
    =======================================
    RUN apt install -y nodejs
    RUN apt install -y npm
    RUN npm i -g chokidar
    

    @smortexa @tiagodevweb

    question 
    opened by amirilidan78 1
  • Not work.

    Not work.

    2022-01-09 00:33:07,664 INFO Set uid to user 0 succeeded
    2022-01-09 00:33:07,666 INFO supervisord started with pid 1
    2022-01-09 00:33:08,668 INFO spawned: 'php_00' with pid 49
    
    
      There are no commands defined in the "octane" namespace.
    
    
    2022-01-09 00:33:09,472 INFO exited: php_00 (exit status 1; not expected)
    2022-01-09 00:33:10,475 INFO spawned: 'php_00' with pid 56
    
    
      There are no commands defined in the "octane" namespace.
    
    
    2022-01-09 00:33:11,269 INFO exited: php_00 (exit status 1; not expected)
    2022-01-09 00:33:13,273 INFO spawned: 'php_00' with pid 63
    
    
      There are no commands defined in the "octane" namespace.
    
    
    2022-01-09 00:33:14,071 INFO exited: php_00 (exit status 1; not expected)
    2022-01-09 00:33:17,076 INFO spawned: 'php_00' with pid 70
    
    
      There are no commands defined in the "octane" namespace.
    
    
    2022-01-09 00:33:17,874 INFO exited: php_00 (exit status 1; not expected)
    2022-01-09 00:33:18,875 INFO gave up: php_00 entered FATAL state, too many start retries too quickly
    
    opened by guoxiangke 1
Releases(v1.2.1)
  • v1.2.1(Aug 18, 2022)

  • v1.2.0(Mar 3, 2022)

    What's Changed

    • Decrease PECL verbosity level by @smortexa in https://github.com/exaco/laravel-octane-dockerfile/pull/11
    • Fix EOL by @smortexa in https://github.com/exaco/laravel-octane-dockerfile/pull/12
    • Add support for OpenSwoole by @smortexa in https://github.com/exaco/laravel-octane-dockerfile/pull/13
    • Improve install commands by @smortexa in https://github.com/exaco/laravel-octane-dockerfile/pull/14
    • Add SHELL instruction by @smortexa in https://github.com/exaco/laravel-octane-dockerfile/pull/15

    Full Changelog: https://github.com/exaco/laravel-octane-dockerfile/compare/v1.1.0...v1.2.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jan 24, 2022)

  • v1.0.0(Dec 29, 2021)

    What's Added

    • added select PHP version in https://github.com/exaco/laravel-octane-dockerfile/commit/b3e57292bef3809835b04a94429fd06c5642c35a
    • added HEALTHCHECK command in https://github.com/exaco/laravel-octane-dockerfile/commit/05c06cb9105ff1a854f36e11c3f0b81ef4adae27
    • run PHP command with octane user in ENTRYPOINT in https://github.com/exaco/laravel-octane-dockerfile/commit/50595990bf876635d7149f035742d62b1c8c0ef1
    • added support for PostgreSQL in https://github.com/exaco/laravel-octane-dockerfile/commit/5eba29dd8a6b2500e6f955606162f736e84df905

    What's Changed

    • added libcurl4-openssl-dev by @tiagodevweb in https://github.com/exaco/laravel-octane-dockerfile/pull/2
    • package:discover command in entrypoint by @tiagodevweb in https://github.com/exaco/laravel-octane-dockerfile/pull/5
    • changed process name in https://github.com/exaco/laravel-octane-dockerfile/commit/48d353621b108d3491ff7637f05b0f63db9ca459

    New Contributors

    • @tiagodevweb made their first contribution in https://github.com/exaco/laravel-octane-dockerfile/pull/2

    Full Changelog: https://github.com/exaco/laravel-octane-dockerfile/compare/v0.0.1...v1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Exalab.co
Exa is a corporation operating in Big-Data, AI-based SaaS industry and focusing on developing NLP-based products.
Exalab.co
PhpBoot is an easy and powerful PHP framework for building RESTful/Microservices APIs.

?? tiny & fast PHP framework for building Microservices/RESTful APIs, with useful features: IOC, Hook, ORM, RPC, Swagger, Annotation, Parameters binding, Validation, etc.

tknet 656 Jan 4, 2023
PHP MicroServices Examples

PHP MicroServices Examples This is a repo of example MicroServices using PHP. Areas of topics will include: Socket Programming RabbitMQ Example RESTFU

Pradeep Sahoo 0 Aug 29, 2022
Rori-PHP is custom non production web application framework inspired by Laravel syntax

Rori-PHP is custom non production web application framework inspired by Laravel syntax. A web framework provides a structure and starting point for your application allowing you to focus on creating something amazing.

UnknownRori 5 Jul 28, 2022
A magic PHP framework. Build reactive web apps without writing HTML, CSS, or JavaScript! Powered by Tailwind, Alpine, Laravel, & Livewire.

Malzahar A magic PHP framework. Build reactive web apps without writing HTML, CSS, or JavaScript! Powered by Tailwind, Alpine, Laravel, & Livewire. Re

null 26 Nov 17, 2022
Kit is a lightweight, high-performance and event-driven web services framework that provides core components such as config, container, http, log and route.

Kit What is it Kit is a lightweight, high-performance and event-driven web services framework that provides core components such as config, container,

null 2 Sep 23, 2022
BEdita, ready to use back-end API, extensible API-first Content Management

BEdita, a back-end API BEdita 4 is a ready to use back-end API to handle the data of your mobile, IoT, web and desktop applications. It's also an exte

BEdita 65 Oct 31, 2022
A set of ready-made regex helper methods for use in your Laravel application.

Regex A set of ready-made regex helper methods for use in your Laravel application. Installation composer require hotmeteor/regex Usage Regex comes wi

Adam Campbell 229 Dec 25, 2022
An application for building micro-services in PHP ^8.

Restolia An application for building micro-services in PHP ^8. Install composer create-project restolia/restolia my-app Services Each service lives i

null 1 May 1, 2022
Motan - a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services

Motan-PHP Overview Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

Weibo R&D Open Source Projects 81 Nov 19, 2022
FlyCubePHP is an MVC Web Framework developed in PHP and repeating the ideology and principles of building WEB applications, embedded in Ruby on Rails.

FlyCubePHP FlyCubePHP is an MVC Web Framework developed in PHP and repeating the ideology and principles of building WEB applications, embedded in Rub

Anton 1 Dec 21, 2021
Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily.

Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily. Leaf introduces a cleaner and much simpler structure to the PHP language while maintaining it's flexibility. With a simple structure and a shallow learning curve, it's an excellent way to rapidly build powerful and high performant web apps and APIs.

Leaf Framework 706 Jan 3, 2023
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

Slim Framework 11.5k Jan 4, 2023
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
Woski is a fast and simple lightweight PHP Framework for building applications in the realm of the web.

Woski is a simple fast PHP framework for the Realm The Project Installation Clone the repository $ composer create-project clintonnzedimma/woski myApp

Clinton Nzedimma 19 Aug 15, 2022
Newsprint is a simple web application that will fetch the front page of a newspaper and display it on an eink display

Newsprint is a simple web application that will fetch the front page of a newspaper and display it on an eink display. The specific resolutions and sizes have been setup to work with a 32" eInk place & play display from Visionect but can be modified for other screen resolutions.

Greg Raiz 199 Dec 20, 2022
TrailLamp is a lightweight, easy-to-use Php MVC framework that can be used to build web applications and REST APIs.

TrailLamp Introduction TrailLamp is a lightweight, easy-to-use Php MVC framework that can be used to build web applications and REST APIs. Installatio

Etorojah Okon 14 Jun 10, 2022
Flare is a PHP full-stack web framework that is light, fast, flexible, and secure.

Flare framework is a PHP full-stack web framework that is simple ,powerful , fast , flexible, and secure with long-term support.

Flare framework 3 Oct 24, 2022
Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

Framework X Framework X – the simple and fast micro framework for building reactive web applications that run anywhere. Quickstart Documentation Tests

Christian Lück 620 Jan 7, 2023