openfaas / templates

OpenFaaS Classic templates
https://www.openfaas.com
MIT License
281 stars 227 forks source link

Provide a PHP 8 template #294

Closed meacu1pa closed 2 years ago

meacu1pa commented 2 years ago

Description

I added a new subfolder in the template directory, containing a PHP 8 template, including the :latest Composer image. Further I had to remove the Phalcon example on installing extensions, because Phalcon right now has no PHP 8 support. It's being worked on, but I don't know when it will be available, so I removed it. The example is still available in the PHP 7 template.

Motivation and Context

As described in #293 , PHP 7's end of life is near, so there is a need for a fresh PHP 8 template. The old template was also locked to an old version of Composer, hence I updated the Dockerfile to always use the latest version of Composer (v2). Also updated classic-watchdog version.

Which issue(s) this PR fixes

Fixes #293.

How Has This Been Tested?

I verified that the build including the extensions example works, and did some simple tests by deploying the resulting image to a VPS running faasd. Also ran ./verify.sh, worked.

Types of changes

Impact to existing users

Existing users will have the chance to create a template using PHP 8, the old PHP 7 template is still available. The php7 template should be removed as soon as PHP 7 reaches end-of-.life (28 Nov 2022). Until then it might be nice to have a fallback solution.

Checklist:

derek[bot] commented 2 years ago

Thank you for your contribution. It seems that one or more of your commits have a "Signed-off-by" statement with an anonymous email address. The Developer Certificate of Origin (DCO) requires all commits to be signed off by genuine, contactable individuals. Please see our contributing guide.

### :bulb: Shall we fix this?

This will only take a few moments.

First, clone your fork and checkout this branch using the git CLI.

Next, set up your real name and email address:

git config --global user.name "Your Full Name" git config --global user.email "you@domain.com"

Finally, run one of these commands to add the "Signed-off-by" line to your commits.

If you only have one commit so far then run: git commit --amend --signoff and then git push --force. If you have multiple commits, watch this video.

Check that the message has been added properly by running "git log".

alexellis commented 2 years ago

Thanks for this PR.

Is Phalcon required or do you think that you could create a new example for us for this template?

meacu1pa commented 2 years ago

Personally I've never used Phalcon. If I were to enable extensions, I would do it the "Docker way", which is already shown in the example.

I spend some time looking for other interesting extensions that would require more work to get it working. Thought of the Blackfire.io probe, but that's a paid product.

Could add it, but imho it's not necessary since all relevant extensions are already available in the alpine image.

alexellis commented 2 years ago

@rgee0 could you give this a run-through with a PHP example on your own cluster?

meacu1pa commented 2 years ago

Small update: I adapted the extension example so it actually installs a PHP extension which is not included in the image.

One little question came up in my mind today, might be worth discussing quickly:

My usual go-to PHP docker image is php:8.1-fpm-alpine. fpm is the FastCGI Process Manager usually used with PHP. Since OpenFaas uses classic-watchdog or of-watchdog for this (if I understood correctly)... would using the fpm-alpine image lead to any edge cases here?

FYI: I stayed with the "normal" -alpine image for this PR, without fpm - same as in the php7 template. Would just be curious if you guys have any insight on this?

alexellis commented 2 years ago

@kevin-lindsay-1 please give this a run through?

@meacu1pa - You may also want to take a look at https://openswoole.com/ which runs a HTTP server, and is more efficient, my prior work: https://github.com/alexellis/php7-swoole-template

kevin-lindsay-1 commented 2 years ago

I have tested this, was able to make a function that has src that differs from the template.

Made it alter the message via return $data . '!!!!!!';

meacu1pa commented 2 years ago

I have tested this, was able to make a function that has src that differs from the template.

Made it alter the message via return $data . '!!!!!!';

From my side it's also good to go.

Let me know if anything is blocking the merge or needs to be changed @alexellis

Cheers 🍻