Skip to content

Commit f9a74a3

Browse files
authored
Merge pull request #104 from bryanlatten/feature-legacy
Dockerfile: added legacy 5.6 variant
2 parents 53ab6b3 + 5370348 commit f9a74a3

File tree

7 files changed

+262
-32
lines changed

7 files changed

+262
-32
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ before_install:
1515
script:
1616
- docker-compose build ubuntu
1717
- docker-compose build edge
18-
- docker-compose build alpine
18+
- docker-compose build legacy

Dockerfile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,29 @@ RUN apt-get update -q && \
4949
RUN apt-get update -q && \
5050
apt-get -yqq install \
5151
php7.0 \
52-
php7.0-fpm \
53-
php7.0-mysql \
54-
php7.0-xml \
52+
php7.0-apcu \
53+
php7.0-bz2 \
5554
php7.0-curl \
55+
php7.0-fpm \
5656
php7.0-gd \
57+
php7.0-gearman \
58+
php7.0-igbinary \
5759
php7.0-intl \
5860
php7.0-json \
5961
php7.0-mbstring \
6062
php7.0-mcrypt \
6163
php7.0-pgsql \
64+
php7.0-memcache \
65+
php7.0-memcached \
66+
php7.0-mysql \
67+
php7.0-redis \
68+
php7.0-xdebug \
69+
php7.0-xml \
70+
php7.0-yaml \
6271
php7.0-zip \
63-
php-apcu \
64-
php-gearman \
65-
php-igbinary \
66-
php-memcache \
67-
php-memcached \
68-
php-redis \
69-
php-xdebug \
70-
php-yaml \
7172
newrelic-php5=${NEWRELIC_VERSION} \
73+
newrelic-php5-common=${NEWRELIC_VERSION} \
74+
newrelic-daemon=${NEWRELIC_VERSION} \
7275
&& \
7376
phpdismod pdo_pgsql && \
7477
phpdismod pgsql && \

Dockerfile-edge

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,26 @@ RUN apt-get update -q && \
4949
RUN apt-get update -q && \
5050
apt-get -yqq install \
5151
php7.1 \
52-
php7.1-fpm \
53-
php7.1-mysql \
54-
php7.1-xml \
52+
php7.1-apcu \
53+
php7.1-bz2 \
5554
php7.1-curl \
55+
php7.1-fpm \
5656
php7.1-gd \
57+
php7.1-igbinary \
5758
php7.1-intl \
5859
php7.1-json \
5960
php7.1-mbstring \
6061
php7.1-mcrypt \
62+
php7.1-mysql \
6163
php7.1-pgsql \
64+
php7.1-gearman \
65+
php7.1-memcache \
66+
php7.1-memcached \
67+
php7.1-xml \
68+
php7.1-yaml \
6269
php7.1-zip \
63-
php-apcu \
64-
php-gearman \
65-
php-igbinary \
66-
php-memcache \
67-
php-memcached \
6870
php-redis \
6971
php-xdebug \
70-
php-yaml \
7172
newrelic-php5=${NEWRELIC_VERSION} \
7273
&& \
7374
phpdismod pdo_pgsql && \

Dockerfile-legacy

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
FROM behance/docker-nginx:6.1
2+
MAINTAINER Bryan Latten <latten@adobe.com>
3+
4+
# Set TERM to suppress warning messages.
5+
ENV CONF_PHPFPM=/etc/php/5.6/fpm/php-fpm.conf \
6+
CONF_PHPMODS=/etc/php/5.6/mods-available \
7+
CONF_FPMPOOL=/etc/php/5.6/fpm/pool.d/www.conf \
8+
CONF_FPMOVERRIDES=/etc/php/5.6/fpm/conf.d/overrides.user.ini \
9+
APP_ROOT=/app \
10+
PHP_FPM_MAX_CHILDREN=4096 \
11+
PHP_FPM_START_SERVERS=20 \
12+
PHP_FPM_MAX_REQUESTS=1024 \
13+
PHP_FPM_MIN_SPARE_SERVERS=5 \
14+
PHP_FPM_MAX_SPARE_SERVERS=128 \
15+
PHP_FPM_MEMORY_LIMIT=256M \
16+
PHP_FPM_MAX_EXECUTION_TIME=60 \
17+
PHP_FPM_UPLOAD_MAX_FILESIZE=1M \
18+
NEWRELIC_VERSION=6.7.0.174
19+
20+
# Ensure cleanup script is available for the next command
21+
ADD ./container/root/clean.sh /clean.sh
22+
23+
# Ensure the latest base packages are up to date (don't require a parent rebuild)
24+
RUN apt-get update -q && \
25+
apt-get upgrade -yqq && \
26+
apt-get install -yqq \
27+
git \
28+
curl \
29+
wget \
30+
software-properties-common \
31+
&& \
32+
locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \
33+
add-apt-repository ppa:git-core/ppa -y && \
34+
add-apt-repository ppa:ondrej/php -y && \
35+
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \
36+
wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \
37+
# Prevent newrelic install from prompting for input \
38+
echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \
39+
echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \
40+
# Perform cleanup \
41+
apt-get remove --purge -yq \
42+
patch \
43+
software-properties-common \
44+
wget \
45+
&& \
46+
/clean.sh
47+
48+
# Add PHP and support packages \
49+
RUN apt-get update -q && \
50+
apt-get -yqq install \
51+
php5.6 \
52+
php5.6-apcu \
53+
php5.6-bz2 \
54+
php5.6-curl \
55+
php5.6-fpm \
56+
php5.6-gd \
57+
php5.6-igbinary \
58+
php5.6-intl \
59+
php5.6-json \
60+
php5.6-mbstring \
61+
php5.6-mcrypt \
62+
php5.6-mysql \
63+
php5.6-pgsql \
64+
php5.6-gearman \
65+
php5.6-memcache \
66+
php5.6-memcached \
67+
php5.6-redis \
68+
php5.6-xdebug \
69+
php5.6-xml \
70+
php5.6-yaml \
71+
php5.6-zip \
72+
newrelic-php5=${NEWRELIC_VERSION} \
73+
newrelic-php5-common=${NEWRELIC_VERSION} \
74+
newrelic-daemon=${NEWRELIC_VERSION} \
75+
&& \
76+
phpdismod pdo_pgsql && \
77+
phpdismod pgsql && \
78+
phpdismod redis && \
79+
phpdismod yaml && \
80+
phpdismod xdebug && \
81+
curl -sS https://getcomposer.org/installer | php && \
82+
mv composer.phar /usr/local/bin/composer && \
83+
/clean.sh
84+
85+
# Temporary Hack: unsupported PHP extensions are dumping old PHP pre-reqs into the mix
86+
# Even marking them to never install doesn't work. Removing for now, until all extensions are supported
87+
RUN apt-get remove --purge -yq \
88+
php5.5 \
89+
php7.0 \
90+
php7.1
91+
92+
# - Configure php-fpm to use TCP rather than unix socket (for stability), fastcgi_pass is also set by /etc/nginx/sites-available/default
93+
# - Set base directory for all php (/app), difficult to use APP_PATH as a replacement, otherwise / breaks command
94+
# - Baseline "optimizations" before benchmarking succeeded at concurrency of 150
95+
# @see http://www.codestance.com/tutorials-archive/install-and-configure-php-fpm-on-nginx-385
96+
# - Ensure environment variables aren't cleaned, will make it into FPM workers
97+
# - php-fpm processes must pick up stdout/stderr from workers, will cause minor performance decrease (but is required)
98+
# - Disable systemd integration, it is not present nor responsible for running service
99+
# - Enforce ACL that only 127.0.0.1 may connect
100+
# - Allow FPM to pick up extra configuration in fpm/conf.d folder
101+
102+
RUN sed -i "s/listen = .*/listen = 127.0.0.1:9000/" $CONF_FPMPOOL && \
103+
sed -i "s/;chdir = .*/chdir = \/app/" $CONF_FPMPOOL && \
104+
sed -i "s/pm.max_children = .*/pm.max_children = \${PHP_FPM_MAX_CHILDREN}/" $CONF_FPMPOOL && \
105+
sed -i "s/pm.start_servers = .*/pm.start_servers = \${PHP_FPM_START_SERVERS}/" $CONF_FPMPOOL && \
106+
sed -i "s/;pm.max_requests = .*/pm.max_requests = \${PHP_FPM_MAX_REQUESTS}/" $CONF_FPMPOOL && \
107+
sed -i "s/pm.min_spare_servers = .*/pm.min_spare_servers = \${PHP_FPM_MIN_SPARE_SERVERS}/" $CONF_FPMPOOL && \
108+
sed -i "s/pm.max_spare_servers = .*/pm.max_spare_servers = \${PHP_FPM_MAX_SPARE_SERVERS}/" $CONF_FPMPOOL && \
109+
sed -i "s/;clear_env/clear_env/" $CONF_FPMPOOL && \
110+
sed -i "s/;catch_workers_output/catch_workers_output/" $CONF_FPMPOOL && \
111+
sed -i "s/error_log = .*/error_log = \/dev\/stdout/" $CONF_PHPFPM && \
112+
sed -i "s/;listen.allowed_clients/listen.allowed_clients/" $CONF_PHPFPM && \
113+
# Since PHP-FPM will be run without root privileges, comment these lines to prevent any startup warnings \
114+
sed -i "s/^user =/;user =/" $CONF_FPMPOOL && \
115+
sed -i "s/^group =/;group =/" $CONF_FPMPOOL && \
116+
# Allow NewRelic to be partially configured by environment variables, set sane defaults \
117+
sed -i "s/newrelic.appname = .*/newrelic.appname = \"\${REPLACE_NEWRELIC_APP}\"/" $CONF_PHPMODS/newrelic.ini && \
118+
sed -i "s/newrelic.license = .*/newrelic.license = \"\${REPLACE_NEWRELIC_LICENSE}\"/" $CONF_PHPMODS/newrelic.ini && \
119+
sed -i "s/newrelic.logfile = .*/newrelic.logfile = \"\/dev\/stdout\"/" $CONF_PHPMODS/newrelic.ini && \
120+
sed -i "s/newrelic.daemon.logfile = .*/newrelic.daemon.logfile = \"\/dev\/stdout\"/" $CONF_PHPMODS/newrelic.ini && \
121+
sed -i "s/;newrelic.loglevel = .*/newrelic.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
122+
sed -i "s/;newrelic.daemon.loglevel = .*/newrelic.daemon.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
123+
# Match FPM timeout directive with .ini max execution time
124+
sed -i "s/;*request_terminate_timeout = .*/request_terminate_timeout = \${PHP_FPM_MAX_EXECUTION_TIME}/" $CONF_FPMPOOL && \
125+
# Required for php-fpm to place .sock file into, fails otherwise \
126+
mkdir /var/run/php/ && \
127+
chown -R $NOT_ROOT_USER:$NOT_ROOT_USER /var/run/php /var/run/lock /var/log/newrelic
128+
129+
# Overlay the root filesystem from this repo
130+
COPY ./container/root /
131+
132+
# Make additional hacks to migrate files/config from 7.0 --> 5.6 folder
133+
RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \
134+
cp /etc/php/7.0/fpm/conf.d/overrides.user.ini $CONF_FPMOVERRIDES && \
135+
# Hack: share startup scripts with php 7.0 version by symlinking \
136+
ln -s /usr/sbin/php-fpm5.6 /usr/sbin/php-fpm7.0 && \
137+
# Override default ini values for both CLI + FPM \
138+
phpenmod overrides && \
139+
# Set nginx to listen on defined port \
140+
sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE && \
141+
# Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars.
142+
phpenmod newrelic && \
143+
sed -i 's/extension\s\?=/;extension =/' $CONF_PHPMODS/newrelic.ini && \
144+
# Enable status page at "/__status"
145+
sed -i 's/;pm.status_path = .*/pm.status_path = \/__status/' $CONF_FPMPOOL
146+
147+
RUN goss -g /tests/php-fpm/legacy.goss.yaml validate && \
148+
/aufs_hack.sh

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,37 @@ Three variants are available:
1010
- (default) Ubuntu-based, PHP 7.0
1111
- (slim) Alpine-based, PHP 7.0, tagged as `-alpine`
1212
- (beta) Ubuntu-based, PHP 7.1, tagged as `-beta`
13+
- (legacy) Ubuntu-based, PHP 5.6, tagged as `-legacy`
1314

1415
###Includes
1516
---
1617
- Nginx
17-
- PHP/PHP-FPM (7.0)
18+
- PHP/PHP-FPM (7.0, 7.1, 5.6)
1819
- Extra PHP Modules:
1920

20-
`*` - not available on Alpine variant
21-
`**` - backwards compatible library not available on Alpine variant
22-
`^` - not available on beta tag
23-
`~` - disabled by default (use `phpenmod` to enable on Ubuntu-based variants, uncomment .ini file otherwise)
24-
- apcu**^
25-
- bz2^
21+
`*` - not available on Alpine variant
22+
`^` - not available on Beta tag
23+
`~` - disabled by default (use `phpenmod` to enable on Ubuntu-based variants, uncomment .ini file otherwise)
24+
- apc*^ (only visible for backwards compatibility)
25+
- apcu^
26+
- calendar
27+
- bz2
2628
- ctype
2729
- curl
30+
- date
2831
- dom
2932
- exif
3033
- fpm
3134
- gd
3235
- gearman*
3336
- iconv
34-
- igbinary*^
37+
- igbinary*
3538
- intl
3639
- json
3740
- mbstring
3841
- mcrypt
3942
- memcache*^
40-
- memcached*^
43+
- memcached*
4144
- mysqli
4245
- mysqlnd
4346
- newrelic~ (activates with env variables)
@@ -61,7 +64,7 @@ Three variants are available:
6164
- xml
6265
- xmlreader
6366
- xmlwriter
64-
- yaml*~
67+
- yaml*~
6568
- zip
6669
- zlib
6770

@@ -97,7 +100,7 @@ Variable | Example | Description
97100
`PHP_FPM_MAX_CHILDREN` | `PHP_FPM_MAX_CHILDREN=15` | [docs](http://php.net/manual/en/install.fpm.configuration.php)
98101
`PHP_FPM_START_SERVERS` | `PHP_FPM_START_SERVERS=128` | [docs](http://php.net/manual/en/install.fpm.configuration.php)
99102
`PHP_FPM_MAX_REQUESTS` | `PHP_FPM_MAX_REQUESTS=1000` | [docs](http://php.net/manual/en/install.fpm.configuration.php) How many requests an individual FPM worker will process before recycling
100-
`PHP_FPM_MIN_SPARE_SERVERS` | `PHP_FPM_MIN_SPARE_SERVERS=5` | [docs](http://php.net/manual/en/install.fpm.configuration.php)
103+
`PHP_FPM_MIN_SPARE_SERVERS` | `PHP_FPM_MIN_SPARE_SERVERS=5` | [docs](http://php.net/manual/en/install.fpm.configuration.php)
101104
`PHP_FPM_MAX_SPARE_SERVERS` | `PHP_FPM_MAX_SPARE_SERVERS=100` | [docs](http://php.net/manual/en/install.fpm.configuration.php)
102105

103106

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Note: base cannot be used because versions are different
2+
# gossfile:
3+
# base.goss.yaml: {}
4+
group:
5+
www-data:
6+
exists: true
7+
command:
8+
php -m:
9+
exit-status: 0
10+
stderr: ['!/./']
11+
php -v:
12+
exit-status: 0
13+
stderr: ['!/./']
14+
php-fpm7.0 -m:
15+
exit-status: 0
16+
stderr: ['!/./']
17+
php-fpm7.0 -v:
18+
exit-status: 0
19+
stderr: ['!/./']
20+
php -r 'echo PHP_MAJOR_VERSION;':
21+
exit-status: 0
22+
stdout: [5]
23+
stderr: ['!/./']
24+
php -r 'echo PHP_MINOR_VERSION;':
25+
exit-status: 0
26+
stdout: [6]
27+
stderr: ['!/./']
28+
29+
package:
30+
php5.6:
31+
installed: true
32+
php5.6-cli:
33+
installed: true
34+
php5.6-curl:
35+
installed: true
36+
php5.6-fpm:
37+
installed: true
38+
php5.6-gd:
39+
installed: true
40+
php5.6-intl:
41+
installed: true
42+
php5.6-json:
43+
installed: true
44+
php5.6-mbstring:
45+
installed: true
46+
php5.6-mysql:
47+
installed: true
48+
php5.6-opcache:
49+
installed: true
50+
php5.6-xml:
51+
installed: true
52+
php5.6-zip:
53+
installed: true
54+
php-yaml:
55+
installed: true

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,23 @@ edge:
5959
- ./container/root/app:/app
6060
- ./container/root/tests/php-fpm/base.goss.yaml:/tests/php-fpm/base.goss.yaml
6161
- ./container/root/tests/php-fpm/beta.goss.yaml:/tests/php-fpm/beta.goss.yaml
62+
legacy:
63+
build: .
64+
dockerfile: Dockerfile-legacy
65+
ports:
66+
- '8083:8080'
67+
environment:
68+
CFG_APP_DEBUG: 1
69+
SERVER_LOG_MINIMAL: 1
70+
PHP_FPM_MEMORY_LIMIT: 257M
71+
PHP_FPM_MAX_EXECUTION_TIME: 61
72+
PHP_FPM_UPLOAD_MAX_FILESIZE: 100M
73+
SERVER_APP_NAME: docker-test
74+
REPLACE_NEWRELIC_APP: abcdefg
75+
REPLACE_NEWRELIC_LICENSE: hijklmno
76+
S6_KILL_FINISH_MAXTIME: 1
77+
S6_KILL_GRACETIME: 1
78+
volumes:
79+
- ./container/root/app:/app
80+
- ./container/root/tests/php-fpm/base.goss.yaml:/tests/php-fpm/base.goss.yaml
81+
- ./container/root/tests/php-fpm/beta.goss.yaml:/tests/php-fpm/legacy.goss.yaml

0 commit comments

Comments
 (0)