基于PHP7.4-fpm的dockerfile
这个是我做某个项目用到的dockerfile,基于php 7.4-fpm的。
就两个文件,一个dockerfile,一个supervisor的配置文件。不废话,上代码:
dockerfile:
FROM php:7.4-fpm
MAINTAINER Dennis "1656239759@qq.com"
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && \
rm -Rf /var/lib/apt/lists/* && \
apt-get update && \
apt-get install -y curl telnet git zlib1g-dev libzip-dev vim procps libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev && \
/bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone && \
docker-php-ext-install zip pdo pdo_mysql opcache mysqli && \
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd && \
docker-php-ext-install -j$(nproc) bcmath && \
apt-get install -y nginx supervisor && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
composer config -g repo.packagist composer https://packagist.phpcomposer.com && \
php -r "unlink('composer-setup.php');" && \
pecl install redis swoole mongodb && \
rm -rf /tmp/pear && \
docker-php-ext-enable redis swoole mongodb && \
apt-get clean && rm -rf /var/cache/apt/*
COPY ./supervisord.conf /etc/supervisor/
WORKDIR /var/www/html
#EXPOSE 80
CMD ["/usr/bin/supervisord"]supervisor:
;守护进程
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
nodaemon=true
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
[program:php]
command=/usr/local/sbin/php-fpm --nodaemonize
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
[program:cron]
command=cron -f两个文件放同级即可,如下图:
