/run-php

Docker container to run PHP apps on Google Cloud Run

Primary LanguageDockerfileMIT LicenseMIT

Docker PHP-FPM 7.4 & nginx on Alpine Linux

Example PHP-FPM 7.4 & nginx setup for Google Cloud Run, build on Alpine Linux.

Details

  • Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs
  • WIP: meant to be used with Firebase: there's a build step to compile required PHP extensions
  • Single file nginx config:
    • default alpine config with a single default host listening on port 8080 (Cloud Run default)
    • host configuration based on Laravel example
    • errors logged to STDERR with warn level, built-in logging is overriden
    • access log is off (Cloud Run logs access on its own)
    • root directory is /run/code/public
    • realip module configured for Cloud Run
    • upload size configured in one place for both nginx and PHP (100M)
    • fastcgi_buffering is off
  • PHP-FPM pool configuration:
    • listens through UNIX socket
    • WIP: static process management
  • Services supervision with runit:
    • nginx service won't start before PHP-FPM socket exists