I'm trying to run Laravel Octane in Docker. I'm using FrankenPHP. When it starts, in log I'm getting lots of:
ERROR PHP Fatal error: Uncaught Error: Class "Laravel\Octane\Octane" not found in /app/vendor/laravel/octane/bin/bootstrap.php:24
Stack trace:
#0 /app/vendor/laravel/octane/bin/frankenphp-worker.php(19): require()
#1 /app/public/frankenphp-worker.php(3): require('...')
#2 {main}
thrown in /app/vendor/laravel/octane/bin/bootstrap.php on line 24
and in a minute container restarts.
Here is my Dockerfile:
FROM dunglas/frankenphp
ENV SERVER_NAME=mysite.com
RUN install-php-extensions pcntl
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git zip unzip nano && \
rm -rf /var/lib/apt/lists//*
RUN docker-php-ext-install pdo pdo_mysql opcache
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY . /app
RUN mv /app/.env.prod /app/.env
RUN composer install \
--no-interaction \
--no-dev \
--optimize-autoloader
RUN php artisan key:generate \
&& php artisan config:clear \
&& php artisan config:cache \
&& php artisan route:cache \
&& php artisan view:cache \
&& php artisan event:cache \
&& php artisan storage:link
ARG USER=laravel
RUN addgroup -gid 1000 ${USER} && useradd -ms /bin/bash -g 1000 ${USER}
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp
RUN chown -R ${USER}:${USER} /data/caddy && chown -R ${USER}:${USER} /config/caddy
USER ${USER}
WORKDIR /app
And here is my docker-compose.yaml:
version: "3.9"
services:
app:
image: "my_username/my_image:latest"
entrypoint: php artisan octane:frankenphp
restart: unless-stopped
hostname: mysite.com
ports:
- "8002:8000"
If I run to check if Octane class is there:
sudo docker exec app_1 ls -l /app/vendor/laravel/octane/src/Octane.php
the file is there.
What can cause this problem?
The problem was in this line in Dockerfile:
Investigating further I found that variables_order in php.ini causes that error. It was
I changed it to:
and it works. Of course this is not ideal solution, I reported this to FrankenPHP and they promised to fix it.
For more information, please check GitHub issue: https://github.com/dunglas/frankenphp/issues/541