These templates use alpine as base images with PHP8.
Images are kept as small as possible.
Two templates are included:
php8using theclassic-watchdogwhich forks PHP scripts.
PHP 8.0
Base image at 33MB (uncompressed).php81using theclassic-watchdogwhich forks PHP scripts.
PHP 8.1
Base image at 35MB.reactphpusing theof-watchdoglaunching a ReactPHP HTTP listener.
PHP 8.1 with ReactPHP
Base image at 38MB.
Find out more of ReactPHP at https://reactphp.org/http/
Retrieve template & create base
faas-cli template pull https://github.com/choval/faas-php-templates
faas-cli new my-serverless-php-function --lang php81
faas-cli new my-reactphp-function --lang reactphpFiles
src/handler.php: the handler functioninstall.sh: executes shell commands on the image, useful for installing packages and binariescomposer.json: php composer dependenciescomposer.lock: optional version locked composer dependencies
This is not secure, a new method will be coming.
To pass a composer auth:
faas-cli build -f ./my-function.yml \
--build-arg COMPOSER_AUTH=`jq -c . < ./auth.json`With auth.json being something like:
{
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "key",
"consumer-secret": "secret"
}
}
}More info: https://getcomposer.org/doc/articles/authentication-for-private-packages.md