php+7.2+fpm+image,GitHub - cube-group/base-image-anp: 基础镜像:alpine3.8+nginx+php-fpm-7.2

1.更新说明

支持grpc依赖扩展grpc、protobuf

环境变量禁用opcache,通过设定ENABLE_OPCACHE=0禁用opcache

支持vim

更新gnu-libiconv解决php iconv的编码问题造成文件上传异常

2.环境变量支持

变量名说明默认值

APP_NAMEapp名称(容器启动时会被自动加入)-

APP_MODEapp所在集群名称(容器启动时会被自动加入)-

APP_NETWORK_USEapp用途名称(容器启动时会被自动加入,包括:web、inner、job)-

APP_PATH项目所在目录(切勿修改)/var/www/html

APP_PATH_INDEXPHP项目index.php入口文件所在目录/var/www/html

APP_PATH_404PHP项目404.html文件所在目录/var/www/html

APP_INIT_SHELL以后台方式执行当前容器初始化脚本,如:php $APP_PATH/init.sh(不建议使用,建议使用supervisor实现)空

APP_MONITOR_HOOKapp报警钉钉群机器人webhook空

ENABLE_OPCACHE是否启用opcache,默认开启,设置为0将不开启1

NGINX_PHP_CONF

default:支持yaf的nginx fastcgi配置

laravel:支持laravel的nginx fastcgi配置(跟yaf一样)

tp:支持thinkphp的nginx fastcgi配置

orc:支持自研老旧php框架的nginx fastcgi配置(强烈建议舍弃)

default

NGINX_LOCATION

特殊nginx location配置,如:rewrite、try_files或其它,如下Dockerfile中可以写为

ENV NGINX_LOCATION "location /web {try_files /web$uri $uri/ /index.php?$args;}"

(强烈建议您直接使用Dockerfile COPY来覆盖/etc/nginx/conf.d/default.conf文件来实现复杂跳转)

PHP_MEM_LIMIT

php单进程内存限制

512M

PHP_POST_MAX_SIZE

php post最大字节100M

PHP_UPLOAD_MAX_FILESIZE

php最大文件上传限制100M

FPM_MAX_CHILDREN

fpm最大子进程数量200

FPM_START_SERVERS

fpm初始子进程数量10

FPM_MIN_SPARE_SERVERS

fpm最大空闲子进程数量8

FPM_MAX_SPARE_SERVERS

fpm最小空闲子进程数量15

FPM_MAX_REQUESTS

fpm每个子进程接受请求数量后会进行垃圾回收200

FPM_SLOWLOG

fpm慢日志文件地址

/var/log/fpm-slow.log

FPM_SLOWLOG_TIMEOUT

php-fpm慢日志超时时间(单位:秒)

2

3.软件版本

PHP 7.2.13 (cli) (built: Dec 7 2018 16:36:58) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

with Zend OPcache v7.2.13, Copyright (c) 1999-2018, by Zend Technologies

[PHP Modules]

amqp

apcu

bcmath

Core

ctype

curl

date

dom

exif

fileinfo

filter

ftp

gd

gmp

grpc

hash

iconv

intl

json

libxml

mbstring

memcached

mongodb

mysqlnd

openssl

pcre

PDO

pdo_mysql

pdo_pgsql

Phar

posix

protobuf

readline

redis

Reflection

session

SimpleXML

soap

sodium

SPL

standard

tokenizer

xml

xmlreader

xmlwriter

xsl

yaf

Zend OPcache

zip

zlib

[Zend Modules]

Zend OPcache

nginx version: nginx/1.14.2

4.supervisor

anp中的所有后台任务都是由supervisord保活的,配置结构如下:

主配置文件:/supervisor.conf (该配置文件不允许被删除,否则会导致容器无法正常启动)

子配置文件:/etc/supervisor/init.conf (默认自带,用于启动环境变量APP_INIT_SHELL中的脚本内容)

子配置文件:/etc/supervisor/monitor.conf (默认自带,用于启动php-fpm进程数监控钉钉报警)

子配置目录:/etc/supervisor/*.conf (supervisor会识别/etc/supervisor/目录下的所有conf文件)

友情连接:supervisor配置文件详解

[program:nginx]

command=/usr/sbin/nginx -g "daemon off;"

autostart=true

autorestart=true

startsecs=3

stdout_logfile=/dev/stdout

redirect_stderr=true

stdout_logfile_maxbytes=0

[program:php-fpm]

command=/usr/sbin/php-fpm7 --nodaemonize

autostart=true

autorestart=true

startsecs=3

stdout_logfile=/dev/stdout

redirect_stderr=true

stdout_logfile_maxbytes=0

[include]

files=/etc/supervisor/*.conf

[program:php-init]

command=php /extra/monitor/init.php

autostart=true

autorestart=false

startsecs=3

stdout_logfile=/dev/stdout

redirect_stderr=true

stdout_logfile_maxbytes=0

[program:php-monitor]

command=php /extra/monitor/start.php

autostart=true

autorestart=true

startsecs=3

stdout_logfile=/dev/stdout

redirect_stderr=true

stdout_logfile_maxbytes=0

5.建议

1、我们强烈建议,覆盖/etc/supervisor/init.conf,放弃对于环境变量APP_INIT_SHELL的使用,转而进行/etc/supervisor/*.conf来实现你想要的初始化脚本执行,例如:

[program:my-init-shell]

directory=/var/www/html #command会在当前目录下执行

command=php bin/cli init/index #执行初始化命令,千万不要执行特殊的业务,因为容器每次部署都会执行

autostart=true #是否自动启动

autorestart=false #是否自动重启,true:保活退出后会自动启动,false:仅执行一次

startsecs=3

stdout_logfile=/dev/stdout

redirect_stderr=true

stdout_logfile_maxbytes=0

2、将您的conf文件放到镜像中

FROM harbor.eoffcn.com/base/anp:stable

COPY supervisor/my-init-shell.conf /etc/supervisor/my-init-shell.conf

3、开启supervisor web GUI

supervisor在daemon条件下运行

[inet_http_server]

port=127.0.0.1:9001

FROM harbor.eoffcn.com/base/anp:stable

COPY supervisor/web-gui.conf /etc/supervisor/web-gui.conf

你可能感兴趣的:(php+7.2+fpm+image,GitHub - cube-group/base-image-anp: 基础镜像:alpine3.8+nginx+php-fpm-7.2)