Closed Aldoo24 closed 4 months ago
Same exact issue when running PHP 8.3 on Debian 12 Bookworm Stable. This is a composer error: "Class DOMDocument not found" which has something to do with PHP-DOM or PHP-XML (even though these are installed).
Removing the composer command will finish the build process (using your Dockerfile) but the resulting binary only serves a blank page.
This is because you install the dependencies with the PHP in the Docker image, not with FrankenPHP.
Just add ext-dom
and the other extensions needed to run your Composer scripts to the Docker image and this will fix the issue.
I am having a hard time adding extensions to this Docker image, how do I do it?
This image is using Alpine, so using apk
to install the required extensions should be enough. What's weird is that we already install ext-dom
by default: https://github.com/dunglas/frankenphp/blob/main/static-builder.Dockerfile#L49
Installing the dom extension using apk
didn't solve the problem. Has anyone found a solution to this?
@Aldoo24 could you provide your full Dockerfile
please? Anyway, as documented, you should prepare your app (this includes running package:discover
on the host, before using the build image. The PHP version provided in the build image is only intended to run Static PHP CLI, not to run commands provided by your app.
This is the Dockerfile
I am using:
FROM --platform=linux/amd64 dunglas/frankenphp:static-builder-1.1.2 # Copy your app WORKDIR /go/src/app/dist/app COPY . . # Build the static binary, be sure to select only the PHP extensions you want WORKDIR /go/src/app/ RUN ./dist/frankenphp-linux-x86_64 version \ export FRANKENPHP_VERSION=1.1.2 \ EMBED=dist/app/ \ ./build-static.sh
I prepared my app using the following steps:
.git
folder like in the documentationAPP_ENV=production
and APP_DEBUG=false
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan event:cache
php artisan route:cache
php artisan view:cache
php artisan optimize
npm run build
Than I build my static app using the Dockerfile
above. The build finishes successfully, but the resulting binary only serves a blank page.
# Build the static binary, be sure to select only the PHP extensions you want
WORKDIR /go/src/app/
RUN ./dist/frankenphp-linux-x86_64 version \
export FRANKENPHP_VERSION=1.1.2 \
EMBED=dist/app/ \
./build-static.sh
This doesn't look valid to me. This should be:
# Build the static binary, be sure to select only the PHP extensions you want
WORKDIR /go/src/app/
RUN ./dist/frankenphp-linux-x86_64 version \
- export FRANKENPHP_VERSION=1.1.2 \
+ FRANKENPHP_VERSION=1.1.2 \
EMBED=dist/app/ \
./build-static.sh
If this doesn't help, could you provide a minimal reproducer or access to your app?
I tried your fix and this time when I accessed the application using http://localhost
it still served a blank page, but when I tried http://localhost/public
I got this error:
Oops! An Error Occurred The server returned a "405 Method Not Allowed". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
When I try sudo ./my-app run
instead of sudo ./my-app php-server
I get a 404 page not found
message.
This time even from http://localhost
, but the same even for http://localhost/public
.
I tried your fix and this time when I accessed the application using
http://localhost
it still served a blank page, but when I triedhttp://localhost/public
I got this error:Oops! An Error Occurred The server returned a "405 Method Not Allowed". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
When I try
sudo ./my-app run
instead ofsudo ./my-app php-server
I get a404 page not found
message. This time even fromhttp://localhost
, but the same even forhttp://localhost/public
.
I have tried both of these methods plus many more and I too receive a blank page when running the resulting binary.
Could you give me access to your apps?
Hi @dunglas I have similar issue when using frankenphp 1.1.1 & 1.1.2
But this issue doesn't happen when I'm using 1.0.3
here is the project source code
FrankenPHP 1.0.3 Commit https://gitlab.com/jimboylabs/blog-rollingsayu/-/tree/03c517d2d6c7769942ccb4b308ba39d5a2f43cab Pipeline Success https://gitlab.com/jimboylabs/blog-rollingsayu/-/jobs/6659822469
FrankenPHP 1.1.2 Commit https://gitlab.com/jimboylabs/blog-rollingsayu/-/tree/22d8ae7b9956ec1faf9cdea83b2bbda273959a2c Pipeline Failed https://gitlab.com/jimboylabs/blog-rollingsayu/-/jobs/6659731610 Error Message
#22 14.86 #19 /go/src/app/dist/app/artisan(35): Illuminate\\Foundation\\Console\\Kernel->handle()
#22 14.86 #20 {main}
#22 14.86 "}
#22 14.87
#22 14.87 In HtmlRenderer.php line 32:
#22 14.87
#22 14.87 Class "DOMDocument" not found
#22 14.87
#22 14.87
#22 14.94 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
#22 ERROR: process "/bin/ash -eo pipefail -c composer install --ignore-platform-reqs --no-dev" did not complete successfully: exit code: 1
That's super weird! I'll take a look.
Here is a workaround while waiting for a new tag:
# Temporary workaround for https://github.com/dunglas/frankenphp/issues/693
RUN apk del composer php82 && \
ln -sf /usr/bin/php83 /usr/bin/php
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
COPY --from=composer/composer:2-bin /composer /usr/bin/composer
thanks @dunglas, works for me now
What happened?
When running
composer install --ignore-platform-reqs --no-dev -a
,php artisan package:discover --ansi
returns the error:My Dockerfile:
Build Type
Standalone binary
Worker Mode
No
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output