Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clean, minimal Nginx-PHP image for Docker/Kubernetes

NotificationsYou must be signed in to change notification settings

parallax/prlx-nginx-php-fpm

Repository files navigation

A relatively clean but full-featured, usable nginx and php-fpm docker image supporting PHP versions 5.6, 7.1, 7.2 maintained byParallax

Docker Tags

PHPNginxDocker tag
5.61.17.0prlx/prlx-nginx-php-fpm:5.6-master
7.11.17.0prlx/prlx-nginx-php-fpm:7.1-master
7.21.17.0prlx/prlx-nginx-php-fpm:7.2-master
7.31.17.0prlx/prlx-nginx-php-fpm:7.3-master

Browse all tags on Docker Hub

Environment Variables

These containers work with certain environment variables to control their operation. Environment variables marked as required may be omitted and things may seem to work OK but we do not test against omitting these so you may see some pretty interesting behaviour as a result.

Web/Worker just means whether these have any effect - nothing bad will happen if they are set on both.

For help running these locally with docker run see thedocker run reference

KeyDescriptionRequiredWebWorker
SITE_NAMEThe name of your project, i.e. 'mywebsite'. Used by NR for app name.
SITE_BRANCHThe running branch of your project, i.e. 'master'. Used by NR for app name.
ENVIRONMENTThe environment you're running in, i.e. 'qa' or 'production'. Used by NR for app name.
ATATUS_APM_LICENSE_KEYYour Atatus license key. Atatus won't be used if this is not set.
ATATUS_APM_RAW_SQLSet to any value (1, true, etc) to use raw sql logging into Atatus
ATATUS_APM_LARAVEL_QUEUESSet to any value (1, true, etc) to use laravel queue transactions in Atatus
NGINX_PORTDefaults to 80
NGINX_WEB_ROOTDefaults to /src/public, use absolute paths if you wish to change this behaviour. Doesn't support '#' in paths!
PHP_MEMORY_MAXMaximum PHP request memory, in megabytes (i.e. '256'). Defaults to 128.
MAX_EXECUTION_TIMEMaximum PHP and Nginx execution/fastcgi read timeout
PHP_FPM_WORKERSMaximum PHP-FPM workers. Defaults to 4 if not set.
DISABLE_OPCACHESet to any value (1, true, etc) to disable PHP Opcache
PHP_OPCACHE_MEMORYMaximum PHP request memory, in megabytes (i.e. '64'). Defaults to 16.
DISABLE_CRONSet to any value (1, true, etc) to disable Cron. Only runs on the worker!
PHP_SESSION_STOREIf not set, PHP uses /tmp for sessions. If set to 'redis', uses redis for sessions
PHP_SESSION_STORE_REDIS_HOSTIf not set, defaults to 'redis'. Only used if PHP_SESSION_STORE is set to redis
PHP_SESSION_STORE_REDIS_PORTIf not set, defaults to 6379. Only used if PHP_SESSION_STORE is set to redis
PHP_DISABLE_CACHE_HEADERSSet to any value (1, true, etc) to disable PHP's default pragma: no-cache headers
PHP_ENABLE_SHORT_TAGSSet to any value (1, true, etc) to enable PHP short tagging

The web mode/command

The web mode is what you use to run a web server - unless you're using workers this is the only one you'll be using. It runs all the things you need to be able to run a PHP-FPM container in Kubernetes.

It is also the default behaviour for the docker containers meaning you don't need to specify a command or working directory to run.

Ports and Services

Not everything is as straightforward as the idealistic world of Docker would have you believe. The "one process per container" doesn't really work for us in the real world so we've gone with "one logical service per container" instead.

We useSupervisord to bootstrap the following services in our Nginx PHP-FPM web mode container:

ServiceDescriptionPort/Socket
NginxWeb server0.0.0.0:80
PHP-FPMPHP running as a pool of workers/run/php.sock

Example Container

There is an example container inexamples/hello-world. To run it:

cd examples/hello-worlddocker build -t example.docker run -p 8080:80 example

You should be able to visit the container onhttp://127.0.0.1:8080/ and see the contents of index.php from /examples/hello-world/src.

Custom Startup Scripts

You can add behaviour to the built-in startup scripts for web, worker or both modes by adding a file to:

File PathRuns on
/startup-all.shAll
/startup-web.shWeb
/startup-worker.shWorker

The worker mode/command

The worker mode is used when you want to run a worker-type task in this container. Usually this means something like php artisan queue:work.

To run in this mode, change the Docker CMD to be /start-worker.sh instead of the default /start-web.sh.

You will need to ship your own worker supervisord jobs by adding these to /etc/supervisord-worker/ in your Dockerfile for your worker. Any .conf files in that directory will be picked up by supervisord to run when in worker mode.

An example of one of these files is provided below - feel free to amend as appropriate:

[program:laravel-queue]command=/usr/bin/php artisan queue:listen directory=/srcautostart=trueautorestart=truepriority=15stdout_events_enabled=truestderr_events_enabled=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0

Cron Jobs on Worker

The worker has support for cron (can be disabled using DISABLE_CRON). To add a crontab, call it the name of the user you want it to run as (probably 'nobody') and ADD it to /etc/cron.d.

Example:

* * * * * date

PHP Modules

Module5.67.17.27.3Notes
apcDeprecated in PHP 7 and up
apcu
bcmath
calendar
Core
ctype
curl
date
dom
eregDeprecated in PHP 7 and up
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
intl
json
ldap
libxml
mbstring
mcryptDeprecated in PHP 7.2 and up
memcached
mysqli
mysqlDeprecated in PHP 7 and up
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tidyWeirdly missing from upstream Alpine Linux repository
tokenizer
wddx
xml
xmlreader
xmlrpcMissing from upstream PHP 7.2
xmlwriter
xsl
Zend OPcache
zip
zlib

About

Clean, minimal Nginx-PHP image for Docker/Kubernetes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp