Open takielias opened 8 months ago
DDEV's goal is to simulate actual deployment environments. At this time there's no intent to work with FrankenPHP because we haven't heard of any deployment environments that use it. But as things grow over the years we'll consider it.
Here is a example for using frankenphp in ddev.
.ddev/web-build/Dockerfile.frankenphp
ARG BASE_IMAGE
FROM $BASE_IMAGE
ENV FRANKENPHP_VERSION=v1.1.0
RUN curl --fail -L -o /usr/local/bin/frankenphp https://github.com/dunglas/frankenphp/releases/download/${FRANKENPHP_VERSION}/frankenphp-linux-$(uname -m) && \
chmod +x /usr/local/bin/frankenphp
ENTRYPOINT ["frankenphp", "run", "--resume", "--watch", "-c", "Caddyfile", "--envfile", ".env", "--pidfile", "/tmp/frankenphp.pid"]
# See if frankenphp is running
HEALTHCHECK --interval=1s --timeout=120s --retries=1 --start-period=120s CMD ps -p $(cat /tmp/frankenphp.pid) > /dev/null; exit $?
Official support would be great. But for now i'm happy to have it running this way.
Please consider creating an add-on for it!
Yea, will have a look. Need to integrate this using supervisord or some other way to ensure the process is restarted once it crashes.
Does it crash often?
You can easily use web_extra_daemons, but if crashes a lot you'd want to put a shell script around it so it restarted.
Well, i'm trying to get TYPO3 to work with it. Once its working properly it should not crash very often.
But having some logic in place to ensure it is running makes sense to me.
As you suggested i'll try to use a bash script.
A very early stage of the addon:
https://github.com/ochorocho/ddev-frankenphp
ddev get ochorocho/ddev-frankenphp && ddev restart
Would be great if anyone could test this and give feedback.
Thank you @ochorocho for your outstanding support. However, I'm facing CORS issues. Could you please guide me on how to resolve them?
i don't know which software you are trying to run. But you may need to set less restrictive cores headers in your app? CORS headers are not my area of expertise. :-)
@takielias you may have a look at https://enable-cors.org/server_caddy.html and use a custom Caddyfile to add the cors confoguration to your project.
@ochorocho I'm using wsl2. When I use nginx/apache I do not face any problems.
@takielias I mean is it Symfony, Laravel or any other app you are trying to run on frankenphp?
@ochorocho Laravel
@ochorocho Do you have any updates?
@takielias no, i'm not using laravel at all. So i can't answer your quesitons on how to get it to work.
@ochorocho, I tried using it with WordPress but get a 404 after running $ ddev get ochorocho/ddev-frankenphp && ddev restart
and trying to access my page.
@fabianmarz haven't used wordpress in a while. I guess you need to change the doc root
in .ddev/frankenphp/Caddyfile
to something like root * /
.
https://github.com/ochorocho/ddev-frankenphp/blob/main/frankenphp/Caddyfile#L36
Thanks for the response. I copied the docroot from the nginx config and set it to /var/www/html
but now I get a 502. With a /
I got a 404 still.
Sorry I'm not very experienced with Caddy and or FrankenPHP to figure out what's the issue here 🙈
ddev logs -f
may help to find some details about the underlying issue.
I'm trying to push Drupal to use FrankenPHP, I'm interested in adding this to DDEV too :) ref: https://www.drupal.org/project/drupal/issues/3437187
If possible, I recommend using the official FrankenPHP image (which uses the "official" PHP image) as a base instead of downloading the static binary. The static binary is compiled using musl and has poorer performance than the glibc version.
@dunglas can you provide details about "poor perf on musl"? I heard this mantra 7 years ago and it's not true for a long time now
See https://github.com/dunglas/frankenphp/pull/666 for details, benchmarks (musl is 2 times slower than glibc under certain conditions), and a potential improvement by replacing the default musl allocator, which performs badly in multi-threaded environments, by mimalloc.
CORS issues are not related to Caddy, FrankenPHP or anything, in itself. It's to do with the allowed origins. The easiest way around it is to add the following to your Caddyfile:
(cors) {
@cors_preflight method OPTIONS
@cors header Origin {args[0]}
handle @cors_preflight {
header Access-Control-Allow-Origin "{args[0]}"
header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Max-Age "3600"
respond "" 204
}
handle @cors {
header Access-Control-Allow-Origin "{args[0]}"
header Access-Control-Expose-Headers "Link"
}
}
Then, in each domain, you can do something like this:
example.ddev.site {
encode zstd gzip
import cors https://example2.ddev.site
root * /var/www/htdocs/public
php_fastcgi frankenphp:9000
file_server
}
Which will allow CORS requests from example2.ddev.site
. Of course, this can be whatever the CORS needs to be.
Is there an existing issue for this?
Is your feature request related to a problem?
FrankenPHP (frankenphp.dev) released its first version a few days ago. Do you have plans to integrate it with DDEV?
Describe your solution
There is a docker image available for quick setup https://frankenphp.dev/docs/docker/
Describe alternatives
No response
Additional context
No response