Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save heartshare/51adf9fe8e0b7b852db68330b7498176 to your computer and use it in GitHub Desktop.
Save heartshare/51adf9fe8e0b7b852db68330b7498176 to your computer and use it in GitHub Desktop.
Docker configuration for Laravel projects with Octane, supporting Open Swoole, Swoole, RoadRunner, and FrankenPHP.

Laravel Octane Docker

Extremely simple Docker setup for Laravel projects with Laravel Octane, using the following application servers:

  • Open Swoole
  • Swoole
  • RoadRunner
  • FrankenPHP

Docker Images

Open Swoole

FROM php:8.3-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN install-php-extensions pcntl sockets openswoole

COPY . /var/www
COPY .env.example /var/www/.env

WORKDIR /var/www

RUN composer install --no-dev

ENTRYPOINT ["php", "artisan", "octane:start", "--server=swoole", "--port=9801", "--workers=16", "--host=0.0.0.0"]

Swoole

FROM php:8.3-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN install-php-extensions pcntl sockets swoole

COPY . /var/www
COPY .env.example /var/www/.env

WORKDIR /var/www

RUN composer install --no-dev

ENTRYPOINT ["php", "artisan", "octane:start", "--server=swoole", "--port=9802", "--workers=16", "--host=0.0.0.0"]

RoadRunner

FROM php:8.3-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
COPY --from=ghcr.io/roadrunner-server/roadrunner:latest /usr/bin/rr /usr/local/bin/rr

RUN install-php-extensions pcntl sockets

COPY . /var/www
COPY .env.example /var/www/.env

WORKDIR /var/www

RUN composer install --no-dev

ENTRYPOINT ["php", "artisan", "octane:start", "--server=roadrunner", "--port=9803", "--workers=16", "--host=0.0.0.0"]

FrankenPHP

FROM php:8.3-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN install-php-extensions pcntl sockets

COPY . /var/www
COPY .env.example /var/www/.env

WORKDIR /var/www

ADD https://github.com/dunglas/frankenphp/releases/latest/download/frankenphp-linux-x86_64 /usr/local/bin/frankenphp
RUN chmod +x /usr/local/bin/frankenphp

RUN composer install --no-dev

ENTRYPOINT ["php", "artisan", "octane:start", "--server=frankenphp", "--port=9804", "--workers=16", "--host=0.0.0.0"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment