Giter Site home page Giter Site logo

dir / laravel-octane-dockerfile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exaco/laravel-octane-dockerfile

0.0 0.0 0.0 201 KB

Production-ready Dockerfile for Laravel Octane (FrankenPHP, Swoole, RoadRunner) powered web services and microservices. Done right.

License: MIT License

Shell 6.10% Dockerfile 93.90%

laravel-octane-dockerfile's Introduction

Laravel Octane Dockerfile

License GitHub release (latest by date) GitHub closed pull requests GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status

Production-ready Dockerfiles for Laravel Octane powered web services and microservices.

The Docker configuration provides the following setup:

  • PHP 8.2 and 8.3 official Debian-based and Alpine-based images
  • Preconfigured JIT compiler and OPcache

Container modes

You can run the Docker container in different modes:

Mode CONTAINER_MODE HTTP server
HTTP Server (default) http FrankenPHP / Swoole / RoadRunner
Horizon horizon -
Scheduler scheduler -
Worker worker -

Usage

Building Docker image

  1. Clone this repository:
git clone --depth 1 [email protected]:exaco/laravel-octane-dockerfile.git
  1. Copy cloned directory content including deployment directory, Dockerfile, and .dockerignore into your Octane powered Laravel project
  2. Change the directory to your Laravel project
  3. Build your image:
docker build -t <image-name>:<tag> -f <your-octane-driver>.Dockerfile .

Running Docker container

# HTTP mode
docker run -p <port>:8000 --rm <image-name>:<tag>

# Horizon mode
docker run -e CONTAINER_MODE=horizon --rm <image-name>:<tag>

# Scheduler mode
docker run -e CONTAINER_MODE=scheduler --rm <image-name>:<tag>

# HTTP mode with Horizon
docker run -e WITH_HORIZON=true -p <port>:8000 --rm <image-name>:<tag>

# HTTP mode with Scheduler
docker run -e WITH_SCHEDULER=true -p <port>:8000 --rm <image-name>:<tag>

# HTTP mode with Scheduler and Horizon
docker run -e WITH_SCHEDULER=true -e WITH_HORIZON=true -p <port>:8000 --rm <image-name>:<tag>

# Worker mode
docker run -e CONTAINER_MODE=worker -e WORKER_COMMAND="php /var/www/html/artisan foo:bar" --rm <image-name>:<tag>

# Running a single command
docker run --rm <image-name>:<tag> php artisan about

Configuration

Recommended Swoole options in octane.php

// config/octane.php

return [
    'swoole' => [
        'options' => [
            'http_compression' => true,
            'http_compression_level' => 6, // 1 - 9
            'compression_min_length' => 20,
            'package_max_length' => 20 * 1024 * 1024, // 20MB
            'open_http2_protocol' => true,
            'document_root' => public_path(),
            'enable_static_handler' => true,
        ]
    ]
];

Utilities

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

Notes

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

ToDo

  • Add support for PHP 8.3
  • Add support for worker mode
  • Build assets with Bun
  • Create standalone and self-executable app
  • Add support for Horizon
  • Add support for RoadRunner
  • Add support for FrankenPHP
  • Add support for the full-stack apps (Front-end assets)
  • Add support testing environment and CI
  • Add support for the Laravel scheduler
  • Add support for Laravel Dusk
  • Support more PHP extensions
  • Add tests
  • Add Alpine-based images

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.

Credits

License

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

laravel-octane-dockerfile's People

Contributors

smortexa avatar sloan58 avatar tiagodevweb avatar gringodotdev avatar miladev95 avatar kichetof avatar dir avatar michael-rubel avatar unilorn avatar denistorresan 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.