Code Monkey home page Code Monkey logo

nuclio-php-runtime's Introduction

nuclio-php-runtime

Runtime for php applications in nuclio

This repository provides a small shim written in golang, which forwards a nuclio event via fcgi to php-fpm through a unix socket.

How does it work

On the first request (coldstart) received by the function a php-fpm server will be started. The php-fpm server is configured to listen on a linux socket ( /var/task/fpm.sock). The request will be forwarded to fpm via the socket and the response will be returned to the clients

Subsequent request to the function will profit from the already running php-fpm server and handle requests faster.

Configuration & Caveats

The current version is opinionated:

  • Per default we assume that a central php script is provided which all requests will be handled (it is responsible for application internal routing). The script can be defined in the Dockerfile (PHP_SCRIPT) or later via the environment vars in the nuclio interface
  • It assumes that the working directory of the function is /var/task - thus the fpm configuration file as well as the source code is put there
  • The Dockerfile utilizes the standard php:fpm container as the basis and adds the nuclio specific options. If you use a different container, please ensure you set PHP_FPM_BIN to the correct path.

Example

The repository contains a example Dockerfile on how to utilize the handler. It can easily be deployed by building the docker image via:

cd example && docker build -t nuclio-php-example:latest

Once it is build, it can be deployed with the following nuclio configuration

apiVersion: "nuclio.io/v1"
kind: NuclioFunction
metadata:
  name: php-example
spec:
  image: nuclio-php-example:latest
  handler: main:Handler
  runtime: golang

For more information on deploying functions via Dockerfiles please refer to the nuclio documentation:

There is also a demo project utilizing the symfony framework

Other Projects

  • bref.sh PHP Runtime for AWS Lambda

Authors

License

Apache

Copyright

Copyright (c) 2019 Patrick Jahns 

nuclio-php-runtime's People

Contributors

patrickjahns avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

nuclio-php-runtime's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.