Switching master to PHP7

This commit is contained in:
Ric Harvey
2017-01-03 09:19:57 +00:00
parent 024ece2ce3
commit bc75013ac4
8 changed files with 73 additions and 64 deletions

View File

@@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file.
## [Unreleased] ## [Unreleased]
### Added ### Added
## [0.1.2] - 2016-7-13 ## [0.2.1] - 2016-7-13
### Added ### Added
- Added options to set PHP values @richarvey - Added options to set PHP values @richarvey
- Added default to hide nginx and php version with overrride @richarvey - Added default to hide nginx and php version with overrride @richarvey
## [0.2.0] - 2016-6-15
### Added
- updated to php7 @richarvey
## [0.1.1] - 2016-6-15 ## [0.1.1] - 2016-6-15
### Added ### Added
- Added php5-gd, php5-intl, php5-memcache, php5-sqlite3, php5-pgsql, php5-xml, php5-xsl @richarvey - Added php5-gd, php5-intl, php5-memcache, php5-sqlite3, php5-pgsql, php5-xml, php5-xsl @richarvey

View File

@@ -2,48 +2,50 @@ FROM nginx:mainline-alpine
MAINTAINER ngineered <support@ngineered.co.uk> MAINTAINER ngineered <support@ngineered.co.uk>
ENV php_conf /etc/php5/php.ini ENV php_conf /etc/php7/php.ini
ENV fpm_conf /etc/php5/php-fpm.conf ENV fpm_conf /etc/php7/php-fpm.d/www.conf
ENV composer_hash aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d ENV composer_hash 61069fe8c6436a4468d0371454cf38a812e451a14ab1691543f25a9627b97ff96d8753d92a00654c21e2212a5ae1ff36
#RUN echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
sed -i -e "s/v3.4/edge/" /etc/apk/repositories && \
echo /etc/apk/respositories && \ echo /etc/apk/respositories && \
apk update && \ apk update && \
apk add --no-cache bash \ apk add --no-cache bash \
openssh-client \ openssh-client \
wget \ wget \
nginx \
supervisor \ supervisor \
curl \ curl \
git \ git \
php5-fpm \ php7-fpm \
php5-pdo \ php7-pdo \
php5-pdo_mysql \ php7-pdo_mysql \
php5-mysql \ php7-mysqlnd \
php5-mysqli \ php7-mysqli \
php5-mcrypt \ php7-mcrypt \
php5-ctype \ php7-mbstring \
php5-zlib \ php7-ctype \
php5-gd \ php7-zlib \
php5-exif \ php7-gd \
php5-intl \ php7-exif \
php5-memcache \ php7-intl \
php5-sqlite3 \ php7-sqlite3 \
php5-pgsql \ php7-pdo_pgsql \
php5-xml \ php7-pgsql \
php5-xsl \ php7-xml \
php5-curl \ php7-xsl \
php5-openssl \ php7-curl \
php5-iconv \ php7-openssl \
php5-json \ php7-iconv \
php5-phar \ php7-json \
php5-soap \ php7-phar \
php5-dom \ php7-soap \
php5-zip \ php7-dom \
php5-redis@testing \ php7-zip \
php7-session \
python \ python \
python-dev \ python-dev \
py-pip \ py2-pip \
augeas-dev \ augeas-dev \
openssl-dev \ openssl-dev \
ca-certificates \ ca-certificates \
@@ -55,17 +57,16 @@ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repo
mkdir -p /etc/nginx && \ mkdir -p /etc/nginx && \
mkdir -p /var/www/app && \ mkdir -p /var/www/app && \
mkdir -p /run/nginx && \ mkdir -p /run/nginx && \
mkdir -p /var/log/supervisor &&\ mkdir -p /var/log/supervisor && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ php7 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('SHA384', 'composer-setup.php') === '${composer_hash}') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \ php7 -r "if (hash_file('SHA384', 'composer-setup.php') === '${composer_hash}') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \ php7 composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');" && \ php7 -r "unlink('composer-setup.php');" && \
pip install -U pip && \ pip install -U pip && \
pip install -U certbot && \ pip install -U certbot && \
mkdir -p /etc/letsencrypt/webrootauth && \ mkdir -p /etc/letsencrypt/webrootauth && \
apk del gcc musl-dev linux-headers libffi-dev augeas-dev python-dev apk del gcc musl-dev linux-headers libffi-dev augeas-dev python-dev
ADD conf/supervisord.conf /etc/supervisord.conf ADD conf/supervisord.conf /etc/supervisord.conf
# Copy our nginx config # Copy our nginx config
@@ -105,8 +106,9 @@ RUN sed -i \
-e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \ -e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
-e "s/^;clear_env = no$/clear_env = no/" \ -e "s/^;clear_env = no$/clear_env = no/" \
${fpm_conf} && \ ${fpm_conf} && \
ln -s /etc/php5/php.ini /etc/php5/conf.d/php.ini && \ ln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini && \
find /etc/php5/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \; find /etc/php7/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;
# Add Scripts # Add Scripts
ADD scripts/start.sh /start.sh ADD scripts/start.sh /start.sh
@@ -118,7 +120,7 @@ RUN chmod 755 /usr/bin/pull && chmod 755 /usr/bin/push && chmod 755 /usr/bin/let
# copy in code # copy in code
ADD src/ /var/www/html/ ADD src/ /var/www/html/
ADD errors/ /var/www/errors/ ADD errors/ /var/www/errors
VOLUME /var/www/html VOLUME /var/www/html

View File

@@ -10,9 +10,11 @@ The Docker hub build can be found here: [https://registry.hub.docker.com/u/richa
## Versions ## Versions
| Tag | Nginx | PHP | Alpine | | Tag | Nginx | PHP | Alpine |
|-----|-------|-----|--------| |-----|-------|-----|--------|
| latest | 1.11.5 | 5.6.27 | 3.4 | | latest | 1.11.5 | 7.0.14 | 3.4@edge |
| php5 | 1.11.5 | 5.6.27 | 3.4 | | php7 | 1.11.5 | 7.0.14 | 3.4@edge |
| php7 | 1.11.5 | 7.0.12 | 3.4 | | php5 | 1.11.5 | 5.6.27 | 3.4 |
**PLEASE NOTE: PHP7 is now the default**
## Building from source ## Building from source
To build from source you need to clone the git repo and run docker build: To build from source you need to clone the git repo and run docker build:
@@ -97,7 +99,7 @@ sudo docker run -d -e 'GIT_NAME=full_name' -e 'GIT_USERNAME=git_username' -e 'GI
``` ```
### Custom Nginx Config files ### Custom Nginx Config files
Sometimes you need a custom config file for nginx to achieve this read the [Nginx config guide](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/nginx_configs.md) Sometimes you need a custom config file for nginx to achieve this read the [Nginx config guide](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/nginx_configs.md)
### Scripting and Templating ### Scripting and Templating
Please see the [Scripting and templating guide](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/scripting_templating.md) for more details. Please see the [Scripting and templating guide](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/scripting_templating.md) for more details.

View File

@@ -1,6 +1,6 @@
server { server {
listen 443 ssl; listen 443 ssl;
listen [::]:443 ssl ipv6only=on; ## listen for ipv6 listen [::]:443 ssl ipv6only=on; ## listen for ipv6
root /var/www/html; root /var/www/html;
index index.php index.html index.htm; index index.php index.html index.htm;
@@ -29,7 +29,7 @@ server {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
} }
error_page 404 /404.html; error_page 404 /404.html;
location = /404.html { location = /404.html {
root /var/www/errors; root /var/www/errors;
internal; internal;
@@ -67,8 +67,8 @@ server {
log_not_found off; log_not_found off;
deny all; deny all;
} }
location ^~ /.well-known { location ^~ /.well-known {
allow all; allow all;
auth_basic off; auth_basic off;
} }

View File

@@ -22,7 +22,7 @@ server {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
} }
error_page 404 /404.html; error_page 404 /404.html;
location = /404.html { location = /404.html {
root /var/www/errors; root /var/www/errors;
internal; internal;
@@ -60,8 +60,8 @@ server {
log_not_found off; log_not_found off;
deny all; deny all;
} }
location ^~ /.well-known { location ^~ /.well-known {
allow all; allow all;
auth_basic off; auth_basic off;
} }

View File

@@ -16,7 +16,7 @@ events {
http { http {
include mime.types; include mime.types;
default_type application/octet-stream; default_type application/octet-stream;
disable_symlinks off;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" ' # '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; # '"$http_user_agent" "$http_x_forwarded_for"';
@@ -29,6 +29,7 @@ http {
#keepalive_timeout 0; #keepalive_timeout 0;
keepalive_timeout 2; keepalive_timeout 2;
client_max_body_size 100m; client_max_body_size 100m;
server_tokens off; server_tokens off;
#gzip on; #gzip on;

View File

@@ -21,8 +21,8 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl] [supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket
[program:php-fpm] [program:php-fpm7]
command = /usr/bin/php-fpm -c /etc/php command = /usr/sbin/php-fpm7 --nodaemonize --fpm-config /etc/php7/php-fpm.d/www.conf
autostart=true autostart=true
autorestart=true autorestart=true
priority=5 priority=5

View File

@@ -13,10 +13,10 @@ fi
# Set custom webroot # Set custom webroot
if [ ! -z "$WEBROOT" ]; then if [ ! -z "$WEBROOT" ]; then
webroot=$WEBROOT webroot=$WEBROOT
sed -i "s#root /var/www/html;#root ${webroot};#g" /etc/nginx/sites-available/default.conf sed -i "s#root /var/www/html;#root ${webroot};#g" /etc/nginx/sites-available/default.conf
else else
webroot=/var/www/html webroot=/var/www/html
fi fi
# Setup git variables # Setup git variables
@@ -62,31 +62,31 @@ fi
# Display PHP error's or not # Display PHP error's or not
if [[ "$ERRORS" != "1" ]] ; then if [[ "$ERRORS" != "1" ]] ; then
echo php_flag[display_errors] = off >> /etc/php5/php-fpm.conf echo php_flag[display_errors] = off >> /etc/php7/php-fpm.conf
else else
echo php_flag[display_errors] = on >> /etc/php5/php-fpm.conf echo php_flag[display_errors] = on >> /etc/php7/php-fpm.conf
fi fi
# Display Version Details or not # Display Version Details or not
if [[ "$HIDE_NGINX_HEADERS" == "0" ]] ; then if [[ "$HIDE_NGINX_HEADERS" == "0" ]] ; then
sed -i "s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf sed -i "s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
else else
sed -i "s/expose_php = On/expose_php = Off/g" /etc/php5/conf.d/php.ini sed -i "s/expose_php = On/expose_php = Off/g" /etc/php7/conf.d/php.ini
fi fi
# Increase the memory_limit # Increase the memory_limit
if [ ! -z "$PHP_MEM_LIMIT" ]; then if [ ! -z "$PHP_MEM_LIMIT" ]; then
sed -i "s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT}M/g" /etc/php5/conf.d/php.ini sed -i "s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT}M/g" /etc/php7/conf.d/php.ini
fi fi
# Increase the post_max_size # Increase the post_max_size
if [ ! -z "$PHP_POST_MAX_SIZE" ]; then if [ ! -z "$PHP_POST_MAX_SIZE" ]; then
sed -i "s/post_max_size = 100M/post_max_size = ${PHP_POST_MAX_SIZE}M/g" /etc/php5/conf.d/php.ini sed -i "s/post_max_size = 100M/post_max_size = ${PHP_POST_MAX_SIZE}M/g" /etc/php7/conf.d/php.ini
fi fi
# Increase the upload_max_filesize # Increase the upload_max_filesize
if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /etc/php5/conf.d/php.ini sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /etc/php7/conf.d/php.ini
fi fi
# Always chown webroot for better mounting # Always chown webroot for better mounting