Sign inSign up

hk01/docker-php

By hk01

•Updated over 5 years ago

[deprecated] check https://gallery.ecr.aws/hk01/docker-php; Base on PHP image, include nginx, php

Image
0

9.3K

hk01/docker-php repository overview

⁠PHP BASE IMAGE

Be based on php official image⁠

⁠Include programs

- php-fpm 7.* - 8.0
- phpunit
- composer
- pecl
- openresty

⁠Default WORKDIR

WORKDIR /srv

⁠Notification

As default, will be removed default php,nginx config file and be generated by ENV PARAMS

  • /usr/local/openresty/nginx/conf/nginx.conf
  • /usr/local/openresty/nginx/conf/vhosts/default.conf
  • /usr/local/etc/php-fpm.conf
  • /usr/local/etc/php/php.ini

⁠PHP 7.0-8.0 modules

⁠Version check list

image⁠phpopenrestycomposerphpunitswoolemongodbmysqlredis
8.0-v0.18.0.31.19.3.11.10.219.5.44.6.61.9.18.0.35.3.4
7.4-v0.17.4.161.19.3.11.10.219.5.44.6.61.9.17.4.165.3.4
7.3-v0.57.3.271.19.3.11.10.219.5.44.6.61.9.15.0.12-dev5.3.4
7.3-v0.47.3.231.19.3.11.10.78.5.134.4.121.9.05.0.12-dev5.3.2
7.2-v0.67.2.341.19.3.11.10.218.5.154.6.61.9.15.0.12-dev5.3.4
7.2-v0.57.2.341.19.3.11.10.78.5.134.3.31.9.05.0.12-dev5.3.2
7.2-v0.47.2.251.15.8.31.10.78.5.54.4.121.7.45.0.12-dev5.2.2
7.2-v0.37.2.251.15.8.31.10.68.5.54.2.31.7.45.0.12-dev5.2.2
7.1-v0.47.1.331.19.3.11.10.217.5.204.4.121.9.15.0.12-dev5.3.4
7.1-v0.37.1.331.19.3.11.10.77.5.204.4.121.9.05.0.12-dev5.3.2
7.0-v0.47.0.331.19.3.11.10.216.5.142.2.01.9.15.0.12-dev5.3.4
7.0-v0.37.0.331.19.3.11.10.76.5.142.2.01.9.05.0.12-dev5.3.2

⁠modules

[PHP Modules]
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
json
libxml
mbstring
memcached
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

⁠init-token.sh

  • bash /script/init-token.sh
  • It will call sys param GITHUB_TOKEN

⁠ENV

  • Default ENV in Dockerfile
# WORKLOAD ARGS

# default is "" , can input nginx,php
PARAMS=""
PARAMS="" 

# php.ini config
PHP_OUTPUT_BUFFERING="4096" 
PHP_DISABLE_FUNCTIONS="passthru,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server" 
PHP_UPLOAD_MAX_FILESIZE="100M" 
PHP_POST_MAX_SIZE="100M" 
PHP_MAX_FILE_UPLOADS="20" 
PHP_MAX_EXECUTION_TIME="600" 
PHP_MAX_INPUT_TIME="600" 
PHP_MEMORY_LIMIT="256M" 
PHP_DATE_TIMEZONE="UTC" 
PHP_DEFAULT_SOCKET_TIMEOUT="60" 

# php-fpm config
PHP_LOG_LEVEL="warning" 
PHP_EMERGENCY_RESTART_THRESHOLD="10" 
PHP_EMERGENCY_RESTART_INTERVAL="1m" 
PHP_PROCESS_CONTROL_TIMEOUT="60s" 
PHP_LISTEN="0.0.0.0:9000" 
PHP_LISTEN_BACKLOG="8192" 
PHP_PM="static" 
PHP_PM_MAX_CHILDREN="15" 
PHP_PM_START_SERVERS="2" 
PHP_PM_MIN_SPARE_SERVERS="2" 
PHP_PM_MAX_SPARE_SERVERS="8" 
PHP_PM_MAX_REQUESTS="102400" 
PHP_REQUEST_TERMINATE_TIMEOUT="65" 
PHP_REQUEST_SLOWLOG_TIMEOUT="2" 

# nginx config
NGINX_ROOT="/srv/public" 
NGINX_CLIENT_MAX_BODY_SIZE="8m" 
NGINX_FASTCGI_PASS="127.0.0.1:9000" 
NGINX_KEEPALIVE_TIMEOUT="600s" 
NGINX_CLIENT_HEADER_TIMEOUT="600s" 
NGINX_CLIENT_BODY_TIMEOUT="600s" 
NGINX_FASTCGI_CONNECT_TIMEOUT="600s" 
NGINX_FASTCGI_SEND_TIMEOUT="600s" 
NGINX_FASTCGI_READ_TIMEOUT="600s" 
NGINX_ACCESS_LOG_FORMAT='[$time_local] " " "$request" " "  $status " " $request_time " "  $upstream_response_time " " $body_bytes_sent " " $http_referer " " "$http_user_agent" " " $remote_addr " " $http_x_forwarded_for' 
 
# php application config
PHP_ENABLE_LARAVEL_CONFIG_CACHE="false" 
PHP_RW_DIRECTORY=""

⁠HOW TO USE

  • Run openresty(nginx)
docker run -ti --rm \
  -e PARAMS=nginx \
  -e NGINX_ROOT="/var/web/www/public" \
  -e NGINX_CLIENT_MAX_BODY_SIZE="100m" \
  hk01/docker-php:7.2-v0.1
  • Run dynamic php-fpm
docker run -ti --rm \
  -e PARAMS=php \
  -e PHP_PM="dynamic" \
  -e PHP_POST_MAX_SIZE="8M" \
  -e PHP_MAX_EXECUTION_TIME="600" \
  -e PHP_RW_DIRECTORY="/srv/a,/srv/b,/srv/c" \
  hk01/docker-php:7.2-v0.1
  • Run static php-fpm
docker run -ti --rm \
  -e PARAMS=php \
  -e PHP_PM="static" \
  -e PHP_PM_MAX_CHILDREN="20" \
  hk01/docker-php:7.2-v0.1
  • Run openresty, php-fpm
docker run -ti --rm \
  -e PARAMS=all \
  hk01/docker-php:7.2-v0.6
  • Use special nginx access log format
docker run -ti --rm \
  -e PARAMS=nginx \
  -e NGINX_ACCESS_LOG_FORMAT='[$time_local] " " \"$request\" " "  $status " " $request_time " "  $upstream_response_time " " $body_bytes_sent " " $http_referer " " \"$http_user_agent\" " " $remote_addr " " $http_x_forwarded_for' \
  hk01/docker-php:7.2-v0.6

⁠Build image example

  • [demo project]
php-docker-demo/
├── Dockerfile
├── README.MD
├── composer.json
└── public
    └── index.php
  • Dockerfile
FROM hk01/docker-php:7.2-v0.6 AS installer

COPY . .

RUN composer install

# build image
FROM hk01/docker-php:7.2-v0.6  AS build

COPY . .

RUN composer install --no-dev --no-progress -o
  • build a image
docker built -t example:v1 .

⁠Thanks

Tag summary

Content type

Image

Digest

Size

207.6 MB

Last updated

over 5 years ago

docker pull hk01/docker-php:7.4.16-fpm-buster-v0.1.178-dev