Merge branch 'master' into stable

This commit is contained in:
Ric Harvey
2015-01-28 11:37:09 +00:00
4 changed files with 29 additions and 12 deletions

View File

@@ -25,7 +25,7 @@ RUN apt-get -y install nginx php5-fpm php5-mysql php-apc pwgen python-setuptools
RUN apt-get -y install php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl RUN apt-get -y install php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl
# tweak nginx config # tweak nginx config
RUN sed -i -e"s/worker_processes 1/worker_processes 5/" /etc/nginx/nginx.conf RUN sed -i -e"s/worker_processes 1/worker_processes 5/" /etc/nginx/nginx.conf # gets over written by start.sh to match cpu's on container
RUN sed -i -e"s/keepalive_timeout\s*65/keepalive_timeout 2/" /etc/nginx/nginx.conf RUN sed -i -e"s/keepalive_timeout\s*65/keepalive_timeout 2/" /etc/nginx/nginx.conf
RUN sed -i -e"s/keepalive_timeout 2/keepalive_timeout 2;\n\tclient_max_body_size 100m/" /etc/nginx/nginx.conf RUN sed -i -e"s/keepalive_timeout 2/keepalive_timeout 2;\n\tclient_max_body_size 100m/" /etc/nginx/nginx.conf
RUN echo "daemon off;" >> /etc/nginx/nginx.conf RUN echo "daemon off;" >> /etc/nginx/nginx.conf
@@ -36,7 +36,13 @@ RUN sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 100M/g" /etc
RUN sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" /etc/php5/fpm/php.ini RUN sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" /etc/php5/fpm/php.ini
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf
RUN sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php5/fpm/pool.d/www.conf RUN sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php5/fpm/pool.d/www.conf
# fix ownership of sock file RUN sed -i -e "s/pm.max_children = 5/pm.max_children = 9/g" /etc/php5/fpm/pool.d/www.conf
RUN sed -i -e "s/pm.start_servers = 2/pm.start_servers = 3/g" /etc/php5/fpm/pool.d/www.conf
RUN sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" /etc/php5/fpm/pool.d/www.conf
RUN sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" /etc/php5/fpm/pool.d/www.conf
RUN sed -i -e "s/pm.max_requests = 500/pm.max_requests = 200/g" /etc/php5/fpm/pool.d/www.conf
# fix ownership of sock file for php-fpm as our version of nginx runs as nginx
RUN sed -i -e "s/user = www-data/user = nginx/g" /etc/php5/fpm/pool.d/www.conf RUN sed -i -e "s/user = www-data/user = nginx/g" /etc/php5/fpm/pool.d/www.conf
RUN sed -i -e "s/group = www-data/group = nginx/g" /etc/php5/fpm/pool.d/www.conf RUN sed -i -e "s/group = www-data/group = nginx/g" /etc/php5/fpm/pool.d/www.conf
RUN sed -i -e "s/listen.owner = www-data/listen.owner = nginx/g" /etc/php5/fpm/pool.d/www.conf RUN sed -i -e "s/listen.owner = www-data/listen.owner = nginx/g" /etc/php5/fpm/pool.d/www.conf
@@ -46,8 +52,11 @@ RUN find /etc/php5/cli/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;
# nginx site conf # nginx site conf
RUN rm -Rf /etc/nginx/conf.d/* RUN rm -Rf /etc/nginx/conf.d/*
ADD ./nginx-site.conf /etc/nginx/conf.d/default.conf RUN mkdir -p /etc/nginx/sites-available/
#RUN sudo usermod -a -G www-data nginx RUN mkdir -p /etc/nginx/sites-enabled/
RUN mkdir -p /etc/nginx/ssl/
ADD ./nginx-site.conf /etc/nginx/sites-available/default.conf
RUN ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf
# add test PHP file # add test PHP file
ADD ./index.php /usr/share/nginx/html/index.php ADD ./index.php /usr/share/nginx/html/index.php
@@ -58,9 +67,6 @@ RUN /usr/bin/easy_install supervisor
RUN /usr/bin/easy_install supervisor-stdout RUN /usr/bin/easy_install supervisor-stdout
ADD ./supervisord.conf /etc/supervisord.conf ADD ./supervisord.conf /etc/supervisord.conf
# Git Pull in here
### TO DO ###
# Start Supervisord # Start Supervisord
ADD ./start.sh /start.sh ADD ./start.sh /start.sh
RUN chmod 755 /start.sh RUN chmod 755 /start.sh

View File

@@ -1,9 +1,9 @@
## Introduction ## Introduction
This is a Dockerfile to build a container image for nginx and php-fpm, with the ability to pull website code from git. The container can also use environment variables to configure your web application using the templating detailed in the [special features](#special-features) section. This is a Dockerfile to build a container image for nginx and php-fpm, with the ability to pull website code from git. The container can also use environment variables to configure your web application using the templating detailed in the [special features](#special-features) section.
## Version ## Version
Mainline Version: **1.7.9** - Mainline Version: **1.7.9**
Stable Version: **1.6.2** - Stable Version: **1.6.2**
*Latest = Mainline Version* - *Latest = Mainline Version*
## Installation ## Installation
Pull the image from the docker index rather than downloading the git repo. This prevents you having to build the image on every docker host. Pull the image from the docker index rather than downloading the git repo. This prevents you having to build the image on every docker host.
```bash ```bash
@@ -25,7 +25,7 @@ If you want to link to your web site directory on the docker host to the contain
sudo docker run --name nginx -p 8080:80 -v /your_code_directory:/usr/share/nginx/html -d richarvey/nginx-php-fpm sudo docker run --name nginx -p 8080:80 -v /your_code_directory:/usr/share/nginx/html -d richarvey/nginx-php-fpm
``` ```
### Pulling code from git ### Pulling code from git
One of the nice features of this container is its ability to pull code from a git repository with a couple of enviromental variables passed at run time. One of the nice features of this container is its ability to pull code from a git repository with a couple of environmental variables passed at run time.
**Note:** You need to have your SSH key that you use with git to enable the deployment. I recommend using a special deploy key per project to minimise the risk. **Note:** You need to have your SSH key that you use with git to enable the deployment. I recommend using a special deploy key per project to minimise the risk.
To run the container and pull code simply specify the GIT_REPO URL including *git@* and then make sure you have a folder on the docker host with your id_rsa key stored in it: To run the container and pull code simply specify the GIT_REPO URL including *git@* and then make sure you have a folder on the docker host with your id_rsa key stored in it:
```bash ```bash
@@ -92,4 +92,4 @@ database_pass = $$_MYSQL_PASS_$$
?> ?>
``` ```
### Template anything ### Template anything
Yes ***ANYTHING***, any variable exposed by a linked container or the **-e** flag lets you template your config files. This means you can add redis, mariaDB, memcache or anything you want to your application very easily. Yes ***ANYTHING***, any variable exposed by a linked container or the **-e** flag lets you template your config files. This means you can add redis, mariaDB, memcache or anything you want to your application very easily.

View File

@@ -38,6 +38,12 @@ server {
include fastcgi_params; include fastcgi_params;
} }
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 5d;
}
# deny access to . files, for security # deny access to . files, for security
# #
location ~ /\. { location ~ /\. {

View File

@@ -10,6 +10,11 @@ if [ ! -z "$GIT_REPO" ]; then
fi fi
fi fi
# Tweak nginx to match the workers to cpu's
procs=$(cat /proc/cpuinfo |grep processor | wc -l)
sed -i -e "s/worker_processes 5/worker_processes $procs/" /etc/nginx/nginx.conf
# Very dirty hack to replace variables in code with ENVIRONMENT values # Very dirty hack to replace variables in code with ENVIRONMENT values
for i in $(env) for i in $(env)