Skip to content

Commit a9019f7

Browse files
authored
Merge pull request #183 from bryanlatten/php-8.0
PHP 8.0: basic implementation
2 parents 64cae09 + db7f30d commit a9019f7

File tree

7 files changed

+205
-134
lines changed

7 files changed

+205
-134
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77
- PHP_VARIANT=7.3
88
- PHP_VARIANT=7.3-alpine
99
- PHP_VARIANT=7.4
10+
- PHP_VARIANT=8.0
1011

1112
services:
1213
- docker

Dockerfile-8.0

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
FROM behance/docker-nginx:8.9
2+
LABEL maintainers="Behance Team <dev-behance@adobe.com>"
3+
4+
# Set TERM to suppress warning messages.
5+
ENV CONF_PHPFPM=/etc/php/8.0/fpm/php-fpm.conf \
6+
CONF_PHPMODS=/etc/php/8.0/mods-available \
7+
CONF_FPMPOOL=/etc/php/8.0/fpm/pool.d/www.conf \
8+
CONF_FPMOVERRIDES=/etc/php/8.0/fpm/conf.d/overrides.user.ini \
9+
APP_ROOT=/app \
10+
SERVER_WORKER_CONNECTIONS=3072 \
11+
SERVER_CLIENT_BODY_BUFFER_SIZE=128k \
12+
SERVER_CLIENT_HEADER_BUFFER_SIZE=1k \
13+
SERVER_CLIENT_BODY_BUFFER_SIZE=128k \
14+
SERVER_LARGE_CLIENT_HEADER_BUFFERS="4 256k" \
15+
PHP_FPM_MAX_CHILDREN=4096 \
16+
PHP_FPM_START_SERVERS=20 \
17+
PHP_FPM_MAX_REQUESTS=1024 \
18+
PHP_FPM_MIN_SPARE_SERVERS=5 \
19+
PHP_FPM_MAX_SPARE_SERVERS=128 \
20+
PHP_FPM_MEMORY_LIMIT=256M \
21+
PHP_FPM_MAX_EXECUTION_TIME=60 \
22+
PHP_FPM_UPLOAD_MAX_FILESIZE=1M \
23+
PHP_OPCACHE_MEMORY_CONSUMPTION=128 \
24+
PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \
25+
PHP_OPCACHE_MAX_WASTED_PERCENTAGE=5 \
26+
PHP_OPCACHE_ENABLE_CLI=1 \
27+
PHP_ENGINE_VERSION=20200930 \
28+
CFG_APP_DEBUG=1
29+
30+
# - Update security packages, only
31+
RUN /bin/bash -e /security_updates.sh && \
32+
apt-get install -yqq --no-install-recommends \
33+
gpg-agent \
34+
git \
35+
curl \
36+
wget \
37+
software-properties-common \
38+
locales \
39+
&& \
40+
locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \
41+
add-apt-repository ppa:ondrej/php -y && \
42+
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \
43+
wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \
44+
# Prevent newrelic install from prompting for input \
45+
echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \
46+
echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \
47+
# Perform cleanup \
48+
apt-get remove --purge -yq \
49+
patch \
50+
software-properties-common \
51+
locales \
52+
wget \
53+
&& \
54+
/bin/bash /clean.sh
55+
56+
# Add PHP and support packages
57+
COPY container/root/usr/local/bin/pecl-install /usr/local/bin
58+
RUN apt-get update -q && \
59+
# Ensure old versions of PHP don't accidentally get added by PPA maintainers
60+
apt-mark hold \
61+
manpages \
62+
manpages-dev \
63+
apache2 \
64+
apache2-bin \
65+
libapache2-mod-php7.4 \
66+
php5.6-cli \
67+
php5.6-common \
68+
php5.6-json \
69+
php7.0-cli \
70+
php7.0-common \
71+
php7.0-json \
72+
php7.1-cli \
73+
php7.1-common \
74+
php7.1-json \
75+
php7.2-cli \
76+
php7.2-common \
77+
php7.2-json \
78+
php7.3-cli \
79+
php7.3-common \
80+
php7.3-json \
81+
php7.4-cli \
82+
php7.4-common \
83+
php7.4-json
84+
85+
RUN apt-get -yqq install \
86+
php8.0 \
87+
php8.0-apcu \
88+
php8.0-bcmath \
89+
php8.0-bz2 \
90+
php8.0-curl \
91+
php8.0-fpm \
92+
php8.0-gd \
93+
php8.0-intl \
94+
php8.0-mbstring \
95+
php8.0-memcache \
96+
php8.0-memcached \
97+
php8.0-mysql \
98+
php8.0-pgsql \
99+
php8.0-redis \
100+
php8.0-xdebug \
101+
php8.0-xml \
102+
php8.0-yaml \
103+
php8.0-zip \
104+
newrelic-php5 \
105+
newrelic-php5-common \
106+
newrelic-daemon \
107+
&& \
108+
/bin/bash /clean.sh \
109+
&& \
110+
phpenmod memcached && \
111+
phpenmod igbinary && \
112+
phpenmod msgpack && \
113+
phpdismod pdo_pgsql && \
114+
phpdismod pgsql && \
115+
phpdismod redis && \
116+
phpdismod yaml && \
117+
phpdismod xdebug && \
118+
# Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder
119+
cd /usr/lib/php && \
120+
ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \
121+
rm -rf /usr/lib/php/7.4 && \
122+
# Remove unused agents for other PHP versions
123+
cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \
124+
cd / && \
125+
curl -sS https://getcomposer.org/installer | php && \
126+
mv composer.phar /usr/local/bin/composer && \
127+
/bin/bash /clean.sh
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 --> 8.0 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 between variant versions by symlinking \
136+
ln -s /usr/sbin/php-fpm8.0 /usr/sbin/php-fpm && \
137+
# Override default ini values for both CLI + FPM \
138+
phpenmod overrides && \
139+
# Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars.
140+
phpenmod newrelic && \
141+
# Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants
142+
/bin/bash -e /prep-php.sh && \
143+
# New 7.3+ specific configuration
144+
sed -i "s/;decorate_workers_output.*/decorate_workers_output = no/" $CONF_FPMPOOL
145+
146+
# HACK: workaround for https://github.com/aelsabbahy/goss/issues/392
147+
# Run the child and parent test configs separately instead of leveraging inheritance
148+
RUN goss -g /tests/php-fpm/8.0.goss.yaml validate && \
149+
goss -g /tests/php-fpm/base.goss.yaml validate && \
150+
/aufs_hack.sh

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/behance/docker-php.svg?branch=master)](https://travis-ci.org/behance/docker-php)
1+
[![Build Status](https://travis-ci.com/behance/docker-php.svg?branch=master)](https://travis-ci.org/behance/docker-php)
22
[![Docker Pulls](https://img.shields.io/docker/pulls/bryanlatten/docker-php.svg?maxAge=2592000)]()
33

44
docker-php
@@ -12,13 +12,13 @@ Available on [Docker Hub](https://hub.docker.com/r/behance/docker-php/).
1212

1313
### Quick-start
1414

15-
- `docker run behance/docker-php:5.6 "php" "-v"`
1615
- `docker run behance/docker-php:7.0 "php" "-v"`
1716
- `docker run behance/docker-php:7.1 "php" "-v"`
1817
- `docker run behance/docker-php:7.2 "php" "-v"`
1918
- `docker run behance/docker-php:7.3-alpine "php" "-v"`
2019
- `docker run behance/docker-php:7.3" "php" "-v"`
2120
- `docker run behance/docker-php:7.4" "php" "-v"`
21+
- `docker run behance/docker-php:8.0" "php" "-v"`
2222

2323
Adding code to runtime, see [here](https://github.com/behance/docker-php#expectations).
2424
PHP tuning and configuration, see [here](https://github.com/behance/docker-php#downstream-configuration).
@@ -27,8 +27,8 @@ Adding startup logic, [basic](https://github.com/behance/docker-base#startuprunt
2727

2828
#### Container tag scheme: `PHP_MAJOR.PHP_MINOR(-Major.Minor.Patch)(-variant)`
2929

30-
- `PHP_MAJOR.PHP_MINOR`, required. Engine versions of PHP. ex. `docker-php:7.4`
31-
- `(Major.Minor.Patch)`, optional. Semantically versioned container provisioning code. ex. `docker-php:7.3-13.4.0`.
30+
- `PHP_MAJOR.PHP_MINOR`, required. Engine versions of PHP. ex. `docker-php:8.0`
31+
- `(Major.Minor.Patch)`, optional. Semantically versioned container provisioning code. ex. `docker-php:7.4-13.4.0`.
3232
- `(-variant)`, optional. Alpine variants are slim versions of the container. ex. `docker-php:7.3-alpine`.
3333

3434
### Includes
@@ -102,10 +102,10 @@ For extension customization, including enabling and disabling defaults, see [her
102102

103103
Sample `Dockerfile`
104104
```
105-
FROM behance/docker-php:7.4
105+
FROM behance/docker-php:8.0
106106
107107
# (optional, recommended) Verify everything is in order from the parent
108-
RUN goss -g /tests/php-fpm/7.4.goss.yaml validate && /aufs_hack.sh
108+
RUN goss -g /tests/php-fpm/8.0.goss.yaml validate && /aufs_hack.sh
109109
110110
# Layer local code into runtime
111111
COPY ./ /app/
@@ -213,10 +213,10 @@ PHP_FPM_LOG_BUFFERING | PHP_FPM_LOG_BUFFERING=no | yes | PHP 7.3+ only [docs](ht
213213
---
214214
- Requires `bash`, `docker`, `docker-compose`, and `dgoss`
215215

216-
To test locally, run `PHP_VARIANT=7.4 ./test.sh {docker engine IP}`.
216+
To test locally, run `PHP_VARIANT=8.0 ./test.sh {docker engine IP}`.
217217

218218
This will:
219-
- Build a single container `PHP_VARIANT` (7.0, 7.1, 7.2, 7.3, 7.3-alpine, 7.4)
219+
- Build a single container `PHP_VARIANT` (7.0, 7.1, 7.2, 7.3, 7.3-alpine, 7.4, 8.0)
220220
- Leverages [Goss](https://goss.rocks) to confirm package, config, and extension installation
221221
- Validates a large file upload
222222
- Boots container with specific NewRelic configuration overrides
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# Extended file tests will be overridden/ignored from parent
3+
# Note: Other variants may not include extended file tests, are not susceptible
4+
# @see https://github.com/aelsabbahy/goss/issues/392
5+
6+
# gossfile:
7+
# base.goss.yaml: {}
8+
9+
command:
10+
# IMPORTANT: confirm the major/minor version of PHP itself
11+
php -r 'echo PHP_MAJOR_VERSION;':
12+
exit-status: 0
13+
stdout: [8]
14+
php -r 'echo PHP_MINOR_VERSION;':
15+
exit-status: 0
16+
stdout: [0]
17+
php-fpm -v:
18+
exit-status: 0
19+
stdout: [PHP 8.0]
20+
# Not common to all variants, test in supported children
21+
php -m | grep -i memcache:
22+
exit-status: 0
23+
24+
# Using workaround commands until https://github.com/aelsabbahy/goss/issues/392 is solved
25+
file:
26+
{{ .Env.CONF_FPMPOOL }}:
27+
exists: true
28+
contains:
29+
- '/^decorate_workers_output = no/'

docker-compose.yml

Lines changed: 0 additions & 126 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
file:
2+
/etc/php/8.0/mods-available/newrelic.ini:
3+
exists: true
4+
mode: "0644"
5+
filetype: file # file, symlink, directory
6+
contains: # Check file content for these patterns
7+
- '/^newrelic.transaction_tracer.enabled = true/'
8+
- '/^newrelic.distributed_tracing_enabled = true/'
9+
- '/^newrelic.loglevel = \"verbosedebug\"/'
10+
- '/^newrelic.daemon.loglevel = \"verbosedebug\"/'
11+
- '/^newrelic.special=debug_autorum/'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
file:
2+
/goss/docker_output.log:
3+
exists: true
4+
filetype: file # file, symlink, directory
5+
contains: # Check file content for these patterns
6+
- '/launching...$/'

0 commit comments

Comments
 (0)