Closed grandrr closed 4 months ago
Hello @grandrr! Instead of
RUN FRANKENPHP_VERSION=1.1.2 \
EMBED=dist/app/ \
PHP_EXTENSIONS=ctype,iconv,pdo_sqlite \
./build-static.sh
Can you instead run the EMBED command first, like this:
RUN EMBED=dist/app/ \
FRANKENPHP_VERSION=1.1.2 \
PHP_EXTENSIONS=... \
./build-static.sh
I'm working on a Dockerfile generator for Laravel apps( fly-apps/dockerfile-laravel ) And I've recently added support to generate a Dockerfile that uses FrankenPHP to build a standalone binary( and get it deployable at Fly.io )! In my journey I've also experienced a similar misconception about running EMBED incorrectly as I've mentioned in a post. See items under ( NOTE! ).
I think that running EMBED first before declaring FRANKENPHP_VERSION should proceed with proper binary generation. ( although it took some time for the build to finish ). And once the build finishes, and you run ./dist/frankenphp-linux-x86_64 php-server
, you should be able to see a log like:
embedded PHP app 📦 {"path": "/tmp/frankenphp_a204c16a3cc7597030296b259d908317 app.tar"}
That should be your sign that the app has been embedded successfully!
Thanks one more time! its working! i got this log:
embedded PHP app 📦 {"path": "/tmp/frankenphp_d5058167b13bd154646861207bd8944c app.tar"}
and it give me response from index.php in public folder, next try will be with real project.
What happened?
So i had try build binary with embed php app, build finish successfully but binary do not include embed php app, or i dont know how to build/use it.
When i had try use dockerfile as described here: https://frankenphp.dev/docs/embed/#creating-a-linux-binary I got error that this is not git folder, after some digging in issues described here i realise that i should add this line:
FRANKENPHP_VERSION=1.1.2
as result my Dockerfile starting looks like:So I had try build container by command:
docker build -t static-app -f static-build.Dockerfile .
This time its build successfully.
After i had try run command for build binary its stuck for some reason. So i remove all section related to run command for build binary, Dockerfile start looks like:
I had build one more time, go inside container and run command inside container.
Run container by command:
docker run -it -p 127.0.0.1:80:80 static-app
after i get inside container in to folder:
/go/src/app
as described in DockerfileAnd in this folder i run command for build binary like this:
FRANKENPHP_VERSION=1.1.2 EMBED=dist/app/ PHP_EXTENSIONS=ctype,iconv,pdo_sqlite ./build-static.sh
As result i get binary file, so i had run it like this:
./dist/frankenphp-linux-x86_64 php-server -v
its executed fine, but after i had try hit in browser: http://127.0.0.1/ I got no response, and logs like this:
So i had try run this one: http://127.0.0.1/index.php and got response in browser:
So this is mean its looking for files in same root as binary is located, so as there is index.php copied from my local machine by command in Dockerfile i had try run it by url: http://127.0.0.1/dist/app/index.php
and got response from my php file.
and my project:
Build Type
Docker (Debian Bookworm)
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output
No response