Skip to content

Commit

Permalink
Switching master to PHP7
Browse files Browse the repository at this point in the history
  • Loading branch information
Ric Harvey committed Jan 3, 2017
1 parent 024ece2 commit bc75013
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 64 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Added

## [0.1.2] - 2016-7-13
## [0.2.1] - 2016-7-13
### Added
- Added options to set PHP values @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
### Added
- Added php5-gd, php5-intl, php5-memcache, php5-sqlite3, php5-pgsql, php5-xml, php5-xsl @richarvey
Expand Down
82 changes: 42 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,50 @@ FROM nginx:mainline-alpine

MAINTAINER ngineered <support@ngineered.co.uk>

ENV php_conf /etc/php5/php.ini
ENV fpm_conf /etc/php5/php-fpm.conf
ENV composer_hash aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d
ENV php_conf /etc/php7/php.ini
ENV fpm_conf /etc/php7/php-fpm.d/www.conf
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 && \
sed -i -e "s/v3.4/edge/" /etc/apk/repositories && \
echo /etc/apk/respositories && \
apk update && \
apk add --no-cache bash \
apk add --no-cache bash \
openssh-client \
wget \
nginx \
supervisor \
curl \
git \
php5-fpm \
php5-pdo \
php5-pdo_mysql \
php5-mysql \
php5-mysqli \
php5-mcrypt \
php5-ctype \
php5-zlib \
php5-gd \
php5-exif \
php5-intl \
php5-memcache \
php5-sqlite3 \
php5-pgsql \
php5-xml \
php5-xsl \
php5-curl \
php5-openssl \
php5-iconv \
php5-json \
php5-phar \
php5-soap \
php5-dom \
php5-zip \
php5-redis@testing \
php7-fpm \
php7-pdo \
php7-pdo_mysql \
php7-mysqlnd \
php7-mysqli \
php7-mcrypt \
php7-mbstring \
php7-ctype \
php7-zlib \
php7-gd \
php7-exif \
php7-intl \
php7-sqlite3 \
php7-pdo_pgsql \
php7-pgsql \
php7-xml \
php7-xsl \
php7-curl \
php7-openssl \
php7-iconv \
php7-json \
php7-phar \
php7-soap \
php7-dom \
php7-zip \
php7-session \
python \
python-dev \
py-pip \
py2-pip \
augeas-dev \
openssl-dev \
ca-certificates \
Expand All @@ -55,17 +57,16 @@ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repo
mkdir -p /etc/nginx && \
mkdir -p /var/www/app && \
mkdir -p /run/nginx && \
mkdir -p /var/log/supervisor &&\
php -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;" && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');" && \
mkdir -p /var/log/supervisor && \
php7 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
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;" && \
php7 composer-setup.php --install-dir=/usr/bin --filename=composer && \
php7 -r "unlink('composer-setup.php');" && \
pip install -U pip && \
pip install -U certbot && \
mkdir -p /etc/letsencrypt/webrootauth && \
apk del gcc musl-dev linux-headers libffi-dev augeas-dev python-dev


ADD conf/supervisord.conf /etc/supervisord.conf

# Copy our nginx config
Expand Down Expand Up @@ -105,8 +106,9 @@ RUN sed -i \
-e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
-e "s/^;clear_env = no$/clear_env = no/" \
${fpm_conf} && \
ln -s /etc/php5/php.ini /etc/php5/conf.d/php.ini && \
find /etc/php5/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;
ln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini && \
find /etc/php7/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;


# Add Scripts
ADD scripts/start.sh /start.sh
Expand All @@ -118,7 +120,7 @@ RUN chmod 755 /usr/bin/pull && chmod 755 /usr/bin/push && chmod 755 /usr/bin/let

# copy in code
ADD src/ /var/www/html/
ADD errors/ /var/www/errors/
ADD errors/ /var/www/errors

VOLUME /var/www/html

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ The Docker hub build can be found here: [https://registry.hub.docker.com/u/richa
## Versions
| Tag | Nginx | PHP | Alpine |
|-----|-------|-----|--------|
| latest | 1.11.5 | 5.6.27 | 3.4 |
| php5 | 1.11.5 | 5.6.27 | 3.4 |
| php7 | 1.11.5 | 7.0.12 | 3.4 |
| latest | 1.11.5 | 7.0.14 | 3.4@edge |
| php7 | 1.11.5 | 7.0.14 | 3.4@edge |
| php5 | 1.11.5 | 5.6.27 | 3.4 |

**PLEASE NOTE: PHP7 is now the default**

## Building from source
To build from source you need to clone the git repo and run docker build:
Expand Down Expand Up @@ -97,7 +99,7 @@ sudo docker run -d -e 'GIT_NAME=full_name' -e 'GIT_USERNAME=git_username' -e 'GI
```

### 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
Please see the [Scripting and templating guide](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/scripting_templating.md) for more details.
Expand Down
8 changes: 4 additions & 4 deletions conf/nginx-site-ssl.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 443 ssl;
listen [::]:443 ssl ipv6only=on; ## listen for ipv6
listen [::]:443 ssl ipv6only=on; ## listen for ipv6

root /var/www/html;
index index.php index.html index.htm;
Expand Down Expand Up @@ -29,7 +29,7 @@ server {
try_files $uri $uri/ =404;
}

error_page 404 /404.html;
error_page 404 /404.html;
location = /404.html {
root /var/www/errors;
internal;
Expand Down Expand Up @@ -67,8 +67,8 @@ server {
log_not_found off;
deny all;
}

location ^~ /.well-known {
location ^~ /.well-known {
allow all;
auth_basic off;
}
Expand Down
6 changes: 3 additions & 3 deletions conf/nginx-site.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ server {
try_files $uri $uri/ =404;
}

error_page 404 /404.html;
error_page 404 /404.html;
location = /404.html {
root /var/www/errors;
internal;
Expand Down Expand Up @@ -60,8 +60,8 @@ server {
log_not_found off;
deny all;
}

location ^~ /.well-known {
location ^~ /.well-known {
allow all;
auth_basic off;
}
Expand Down
3 changes: 2 additions & 1 deletion conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ events {
http {
include mime.types;
default_type application/octet-stream;
disable_symlinks off;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
Expand All @@ -29,6 +29,7 @@ http {
#keepalive_timeout 0;
keepalive_timeout 2;
client_max_body_size 100m;

server_tokens off;
#gzip on;

Expand Down
4 changes: 2 additions & 2 deletions conf/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket

[program:php-fpm]
command = /usr/bin/php-fpm -c /etc/php
[program:php-fpm7]
command = /usr/sbin/php-fpm7 --nodaemonize --fpm-config /etc/php7/php-fpm.d/www.conf
autostart=true
autorestart=true
priority=5
Expand Down
18 changes: 9 additions & 9 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fi

# Set custom webroot
if [ ! -z "$WEBROOT" ]; then
webroot=$WEBROOT
sed -i "s#root /var/www/html;#root ${webroot};#g" /etc/nginx/sites-available/default.conf
webroot=$WEBROOT
sed -i "s#root /var/www/html;#root ${webroot};#g" /etc/nginx/sites-available/default.conf
else
webroot=/var/www/html
webroot=/var/www/html
fi

# Setup git variables
Expand Down Expand Up @@ -62,31 +62,31 @@ fi

# Display PHP error's or not
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
echo php_flag[display_errors] = on >> /etc/php5/php-fpm.conf
echo php_flag[display_errors] = on >> /etc/php7/php-fpm.conf
fi

# Display Version Details or not
if [[ "$HIDE_NGINX_HEADERS" == "0" ]] ; then
sed -i "s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
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

# Increase the memory_limit
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

# Increase the post_max_size
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

# Increase the upload_max_filesize
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

# Always chown webroot for better mounting
Expand Down

0 comments on commit bc75013

Please sign in to comment.