diff --git a/README.md b/README.md index 9ea42e77..7f781811 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ See: `faas-cli template store list` to see which templates are both: recommended | java11-vert-x | Java and [Vert.x](https://vertx.io/) | 11 | Debian GNU/Linux | of-watchdog | [Java LTS template](https://github.com/openfaas/templates/tree/master/template/java11-vert-x) | java11 | Java | 11 | Debian GNU/Linux | of-watchdog | [Deprecated Java template](https://github.com/openfaas/templates/tree/master/template/java11) | java17 | Java | 11 | Debian GNU/Linux | of-watchdog | [Java LTS template](https://github.com/openfaas/templates/tree/master/template/java17) -| php7 | PHP | 7.4 | Alpine Linux | classic | [PHP 7 template](https://github.com/openfaas/templates/tree/master/template/php7) | php8 | PHP | 8.2 | Alpine Linux | classic | [PHP 8 template](https://github.com/openfaas/templates/tree/master/template/php8) For more information on the templates check out the [docs](https://docs.openfaas.com/cli/templates/). diff --git a/template/php7/Dockerfile b/template/php7/Dockerfile deleted file mode 100644 index 9c91a94f..00000000 --- a/template/php7/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.4 AS watchdog - -# start with the official Composer image and name it -FROM --platform=${TARGETPLATFORM:-linux/amd64} composer:1 AS composer - -# continue with the official PHP image -FROM --platform=${TARGETPLATFORM:-linux/amd64} php:7.4-alpine - -# copy the Composer PHAR from the Composer image into the PHP image -COPY --from=composer /usr/bin/composer /usr/bin/composer - -# Composer requirements -ARG COMPOSER_AUTH='{}' -ENV COMPOSER_AUTH=${COMPOSER_AUTH} - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog - -RUN apk add --no-cache git - -# create non-root user -RUN addgroup -S app && adduser -S -g app app && \ - mkdir -p /home/app - -# Import function -WORKDIR /home/app -COPY index.php ./ -COPY ./function ./function -WORKDIR /home/app/function - -# Install php extensions -RUN [[ -f php-extension.sh ]] && sh ./php-extension.sh && \ - chown -R app /home/app - -# Entry -USER app - -# Install Composer Dependecies -RUN [[ -f composer.lock || -f composer.json ]] && composer install --no-dev - -USER root - -# Cleanup -RUN apk del git && \ - rm -rf /usr/src/php && \ - { find /usr/local/lib -type f -print0 | xargs -0r strip --strip-all -p 2>/dev/null || true; } - -USER app - -WORKDIR /home/app -ENV fprocess="php index.php" -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 -CMD ["fwatchdog"] diff --git a/template/php7/function/composer.json b/template/php7/function/composer.json deleted file mode 100644 index ae4f40e0..00000000 --- a/template/php7/function/composer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "openfaas/function-php7.2", - "description": "Template for function in PHP 7.2", - "type": "project", - "license": "proprietary", - "config": { - "classmap-authoritative": true - }, - "autoload": { - "psr-4": { - "App\\": "src/" - } - }, - "require": { - "php": "^7.2" - } -} diff --git a/template/php7/function/php-extension.sh b/template/php7/function/php-extension.sh deleted file mode 100644 index 725ec223..00000000 --- a/template/php7/function/php-extension.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -echo "Installing PHP extensions" - -# Add your extensions in here, an example is below -# docker-php-ext-install mysqli -# -# See the template documentation for instructions on installing extensions; -# - https://github.com/openfaas/templates/tree/master/template/php7 -# -# You can also install any apk packages here diff --git a/template/php7/function/src/Handler.php b/template/php7/function/src/Handler.php deleted file mode 100644 index cd9549cd..00000000 --- a/template/php7/function/src/Handler.php +++ /dev/null @@ -1,19 +0,0 @@ -handle($stdin); -echo $response; diff --git a/template/php7/php-extension.sh-example b/template/php7/php-extension.sh-example deleted file mode 100644 index db91b0bd..00000000 --- a/template/php7/php-extension.sh-example +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -echo "Installing PHP extensions" -docker-php-ext-install pdo_mysql - -# Install Phalcon -PHALCON_VERSION=3.4.0 -PHALCON_EXT_PATH=php7/64bits - -set -xe && \ - # Compile Phalcon - curl -LO https://github.com/phalcon/cphalcon/archive/v${PHALCON_VERSION}.tar.gz && \ - tar xzf ${PWD}/v${PHALCON_VERSION}.tar.gz && \ - docker-php-ext-install -j $(getconf _NPROCESSORS_ONLN) ${PWD}/cphalcon-${PHALCON_VERSION}/build/${PHALCON_EXT_PATH} && \ - # Remove all temp files - rm -r \ - ${PWD}/v${PHALCON_VERSION}.tar.gz \ - ${PWD}/cphalcon-${PHALCON_VERSION} \ No newline at end of file diff --git a/template/php7/readme.md b/template/php7/readme.md deleted file mode 100644 index 95738e81..00000000 --- a/template/php7/readme.md +++ /dev/null @@ -1,41 +0,0 @@ -# PHP7 Template - -Templates are built using the latest minor version of the major release. - -| Modules (by default) | -| ------------- | -| Core, date, libxml, openssl, pcre, sqlite3, zlib, ctype, curl, dom, fileinfo, filter, ftp, hash, iconv, json, mbstring, SPL, PDO, pdo_sqlite, session, posix, readline, Reflection, standard, SimpleXML, Phar, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, sodium | - -## Usage: - -```shell -faas-cli new my-function --lang php7 -``` - -You will find in the newly created directory `my-function`: - -- `src/Handler.php` : entrypoint -- `php-extension.sh` : is for installing PHP extensions if needed -- `composer.json` : is for dependency management - -## Extra Extensions - -If you need to install [Phalcon](https://github.com/phalcon) for example, check out the -following sample which you could use in your functions `src/php-extension.sh` file; - -- [php-extension.sh-example](php-extension.sh-example) - -You can also refer to the PHP Docker image [documentation](https://github.com/docker-library/docs/blob/master/php/README.md#how-to-install-more-php-extensions) for additional instructions on the installation and configuration of extensions - -## Private Composer Auth - -In some cases, you may need to use private composer repositories - using the `faas-cli` you can pass in -a build argument during build, for example; - -``` -faas-cli build -f ./functions.yml \ - --build-arg COMPOSER_AUTH='{"bitbucket-oauth": {"bitbucket.org": {"consumer-key": "xxxxxxxx","consumer-secret": "xxxxxxx"}}}' -``` -See more information [here](https://getcomposer.org/doc/05-repositories.md#git-alternatives). - -That way you can pass in tokens for Composer, if necessary, GitHub tokens to get around rate-limit issues. diff --git a/template/php7/template.yml b/template/php7/template.yml deleted file mode 100644 index 4c0ecfb9..00000000 --- a/template/php7/template.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: php7 -fprocess: php index.php -welcome_message: | - You have created a new function which uses PHP 7.4. - Dependencies and extensions can be added using the composer.json - and php-extension.sh files. - See https://github.com/openfaas/templates/blob/master/template/php7. diff --git a/template/php8/Dockerfile b/template/php8/Dockerfile index 19531c55..b0560144 100644 --- a/template/php8/Dockerfile +++ b/template/php8/Dockerfile @@ -19,6 +19,12 @@ ENV COMPOSER_AUTH=${COMPOSER_AUTH} COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +# The Classic Watchdog passes HTTP bodies to PHP CLI over stdin, so PHP's +# RFC1867 upload progress feature is unused. Keep it disabled as defence in +# depth for functions which customise the PHP execution mode. +RUN printf '%s\n' 'session.upload_progress.enabled=Off' > \ + /usr/local/etc/php/conf.d/openfaas-security.ini + RUN apk add --no-cache git # create non-root user