軟件:PHP 7.二、Nginx、MySQL、Composer、NPM AND Yarn 等等; 易於擴展使用,如隨時能夠切換 PHP 版本,或者 Apache 和 Nginx 切換使用。 規劃: 先在centos鏡像安裝php-fpm和laravel的須要依賴包,使用supervisord監控php-fpm的啓動,而後經過掛載項目的目錄到容器以內 執行腳本構建項目。實現項目發佈和更新迭代。 此處我僅僅處理了lavravel的php和依賴環境,並無處理nginx和mysql的環境,後期會出關於其餘依賴的環境的操做。
我這裏懶省事直接在容器裏面安裝處理了(開啓模塊: opcache imagick fileinfo redis swoole ) wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --php_option 7 --phpcache_option 1 --php_extensions zendguardloader,ioncube,imagick,fileinfo,redis,swoole
我這裏選擇 node-v10.10.0-linux-x64.tar.gz wget https://nodejs.org/download/release/v10.10.0/node-v10.10.0-linux-x64.tar.gz tar xf node-v10.10.0-linux-x64.tar.gz mv node-v10.10.0 /usr/local/node
wget install -y https://github.com/yarnpkg/yarn/releases/download/v1.13.0/yarn-1.13.0-1.noarch.rpm yum install -y yarn-1.13.0-1.noarch.rpm
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
cd /usr/local/bin curl -s https://getcomposer.org/installer | php chmod a+x composer.phar composer.phar self-update mv composer.phar composer
yum install -y epel-release yum install -y supervisor
[root@58b32f9d29d0 /]# cat /root/startphp-fpm.sh #!/bin/bash supervisord -n -c /etc/supervisord.conf [root@58b32f9d29d0 /]# cat /etc/supervisord.conf |grep -vE "^;|^$" [unix_http_server] file=/var/run/supervisor/supervisor.sock ; (the path to the socket file) [supervisord] logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) loglevel=info ; (log level;default info; others: debug,warn,trace) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=false ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket [program:php-fpm] process_name=%(program_name)s_%(process_num)02d command=/usr/local/php/sbin/php-fpm --fpm-config /usr/local/php/etc/php-fpm.conf #stdout_logfile=/data/wwwlogs/php-fpm-sup.log autostart=true autorestart=true startretries=5 exitcodes=0,2,70 stopsignal=QUIT stopwaitsecs=2 [include] files = supervisord.d/*.ini
rm -fr oneinstack-full.tar.gz oneinstack yarn-1.13.0-1.noarch.rpm node-v10.10.0-linux-x64.tar.gz yum cleal all
docker commit -a "laravel 環境初始化" 58b32f9d29d0 hanye131/fangxinerp:supvisor_php-fpm72
docker run -itd --name=test1 -v /data/startphp-fpm.sh:/root/startphp-fpm.sh -v /data/supervisord.conf:/etc/supervisord.conf hanye131/fangxinerp:supvisor_php-fpm72
docker run -itd --name=test1 -v /data/startphp-fpm.sh:/root/startphp-fpm.sh -v /data/supervisord.conf:/etc/supervisord.conf -v /var/www/html:/var/www/html -v /root/laravel-install.sh:/root/laravel-install.sh: hanye131/fangxinerp:supvisor_php-fpm72
#!/bin/bash export PATH=/usr/local/php/bin:/usr/local/php/sbin:/usr/local/node/bin:$PATH cd /var/www/html composer install yarn install php artisan migrate --force php artisan queue:restart npm run dev
FROM centos:latest MAINTAINER hz7726@163.com ENV PATH /usr/local/php/bin:/usr/local/php/sbin:/usr/local/node/bin:$PATH RUN yum install -y wget \ && mkdir -p /data/docker \ && cd /data/docker \ && wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --php_option 7 --phpcache_option 1 --php_extensions zendguardloader,imagick,fileinfo,redis,swoole \ && wget https://nodejs.org/download/release/v10.10.0/node-v10.10.0-linux-x64.tar.gz \ && tar xf node-v10.10.0-linux-x64.tar.gz \ && mv node-v10.10.0-linux-x64 /usr/local/node \ && curl -sL https://rpm.nodesource.com/setup_8.x | bash - \ && wget https://github.com/yarnpkg/yarn/releases/download/v1.13.0/yarn-1.13.0-1.noarch.rpm \ && yum install -y yarn-1.13.0-1.noarch.rpm COPY php_etc.tar.gz /usr/local/php/etc/ RUN cd /usr/local/php/etc/ \ && tar xf php_etc.tar.gz #COPY /data/php-fpm /etc/init.d/php-fpm #COPY /data/composer /usr/local/bin/composer #RUN chmod +x /etc/init.d/php-fpm \ #&& chkconfig --add php-fpm \ && sed -i 's@disable_functions@;disable_functions@' /usr/local/php/etc/php.ini\ && rm -fr /data/docker && yum cleal all CMD ['/usr/local/php/sbin/php-fpm','--fpm-config','/usr/local/php/etc/php-fpm.conf']
https://gitee.com/hanyehell/DockerInstall/tree/master/docker-Laravel-php-fpmphp