forked from richarvey/nginx-php-fpm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
72 lines (57 loc) · 2.6 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
FROM centos:7
MAINTAINER Kat Andry ([email protected])
ENV container docker
# Install supervisord
RUN \
yum update -y && \
yum install -y epel-release && \
yum install -y iproute python-setuptools hostname inotify-tools yum-utils which && \
yum clean all && \
easy_install supervisor
# Install nginx
RUN rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm && \
yum -y install nginx
# Install webtatic repo
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# Install php-fpm etc
RUN yum -y install php56w-fpm php56w-mysql php56w-ldap php56w-cli php56w-mbstring php56w-pdo php56w-pear php56w-xml php56w-soap php56w-intl
# Install git too
RUN yum -y install git
# tweak php-fpm config
RUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php.ini && \
sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 100M/g" /etc/php.ini && \
sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" /etc/php.ini && \
sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php-fpm.conf && \
sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.max_children = 5/pm.max_children = 9/g" /etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.start_servers = 2/pm.start_servers = 3/g" /etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" /etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" /etc/php-fpm.d/www.conf && \
sed -i -e "s/pm.max_requests = 500/pm.max_requests = 200/g" /etc/php-fpm.d/www.conf
# tweak nginx config
RUN sed -i -e"s/worker_processes 1/worker_processes 5/" /etc/nginx/nginx.conf && \
sed -i -e"s/keepalive_timeout\s*65/keepalive_timeout 2/" /etc/nginx/nginx.conf && \
sed -i -e"s/keepalive_timeout 2/keepalive_timeout 2;\n\tclient_max_body_size 100m/" /etc/nginx/nginx.conf && \
echo "daemon off;" >> /etc/nginx/nginx.conf
# nginx site conf
RUN rm -Rf /etc/nginx/conf.d/* && \
mkdir -p /etc/nginx/ssl/
ADD conf/nginx-site.conf /etc/nginx/conf.d/default.conf
# Add git commands to allow container updating
ADD scripts/pull /usr/bin/pull
ADD scripts/push /usr/bin/push
RUN chmod 755 /usr/bin/pull && chmod 755 /usr/bin/push
# Supervisor Config
ADD conf/supervisord.conf /etc/supervisord.conf
# Start Supervisord
ADD scripts/start.sh /start.sh
RUN chmod 755 /start.sh
# Setup Volume
VOLUME ["/usr/share/nginx/html"]
# add test PHP file
ADD src/index.php /usr/share/nginx/html/index.php
RUN chown -Rf nginx.nginx /usr/share/nginx/html/
# Expose Ports
EXPOSE 443
EXPOSE 80
CMD ["/bin/bash", "/start.sh"]