Skip to content

Commit 3b3e95c

Browse files
committed
add support for php8 images
1 parent 6cd492b commit 3b3e95c

28 files changed

+1001
-16
lines changed

8.0-dev/Dockerfile

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
FROM php:8.0-apache
2+
3+
# common-php70
4+
ENV DEBIAN_FRONTEND noninteractive
5+
ENV APACHE_DOCROOT /var/www/html
6+
ENV PATH=/var/www/vendor/bin:$PATH
7+
ENV COMPOSER_MEMORY_LIMIT "-1"
8+
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
# for bz2
11+
bzip2 libbz2-dev \
12+
# for ftp
13+
libssl-dev \
14+
# for gd
15+
libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
16+
# for intl
17+
libicu-dev \
18+
# for dom
19+
libxml2-dev \
20+
# for ldap
21+
libldap2-dev \
22+
# for mysql
23+
mariadb-client \
24+
# for ssh client only
25+
openssh-client \
26+
# For image optimization
27+
jpegoptim \
28+
optipng \
29+
pngquant \
30+
# php7.3 needs zlib1g-dev and libzip-dev for the zip extension
31+
# https://github.com/docker-library/php/issues/61#issuecomment-468874705
32+
zlib1g-dev \
33+
libzip-dev \
34+
# for git
35+
git \
36+
# for composer
37+
unzip \
38+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
39+
40+
RUN docker-php-ext-configure gd \
41+
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu \
42+
&& docker-php-ext-install -j$(nproc) \
43+
bcmath \
44+
bz2 \
45+
calendar \
46+
exif \
47+
ftp \
48+
gd \
49+
gettext \
50+
intl \
51+
ldap \
52+
mysqli \
53+
opcache \
54+
pcntl \
55+
pdo_mysql \
56+
shmop \
57+
soap \
58+
sockets \
59+
sysvmsg \
60+
sysvsem \
61+
sysvshm \
62+
zip \
63+
&& pecl install redis apcu \
64+
&& docker-php-ext-enable redis apcu
65+
66+
# Configure Apache:
67+
RUN a2enmod rewrite headers expires \
68+
&& sed -i "/DocumentRoot \/var\/www\/html/c\\\tDocumentRoot \$\{APACHE_DOCROOT\}" /etc/apache2/sites-enabled/000-default.conf \
69+
# Preemptively add a user 1000, for use with $APACHE_RUN_USER on osx
70+
&& adduser --uid 1000 --gecos 'My OSX User' --disabled-password osxuser
71+
72+
# Install Composer.
73+
74+
ARG COMPOSER_VERSION=2.3.10
75+
RUN COMPOSER_SHA384=$(curl https://composer.github.io/installer.sig) \
76+
&& curl -fsSL -o composer-setup.php https://getcomposer.org/installer \
77+
&& echo "$COMPOSER_SHA384 composer-setup.php" | sha384sum -c - \
78+
&& php composer-setup.php --version=$COMPOSER_VERSION --install-dir=/usr/local/bin --filename=composer
79+
80+
# Install Dockerize.
81+
ARG DOCKERIZE_VERSION=v0.6.1
82+
ARG DOCKERIZE_SHA256=1fa29cd41a5854fd5423e242f3ea9737a50a8c3bcf852c9e62b9eb02c6ccd370
83+
RUN curl -fsSOL https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
84+
&& echo "$DOCKERIZE_SHA256 dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz" | sha256sum -c - \
85+
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
86+
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
87+
88+
# Install Drush Launcher. Whereas previously we installed Drush globally, we no longer do,
89+
# since it's expected that D8 sites will include their own copy of Drush, and Drush 9+ is
90+
# incompatible with Drupal < 8.
91+
# @todo: Is the launcher even needed? We add /var/www/vendor/bin on the global path.
92+
ARG DRUSH_LAUNCHER_VERSION=0.6.0
93+
ARG DRUSH_LAUNCHER_SHA256=c3f32a800a2f18470b0010cd71c49e49ef5c087f8131eecfe9b686dc1f3f3d4e
94+
RUN curl -fsSOL https://github.com/drush-ops/drush-launcher/releases/download/$DRUSH_LAUNCHER_VERSION/drush.phar \
95+
&& echo "$DRUSH_LAUNCHER_SHA256 drush.phar" | sha256sum -c - \
96+
&& mv drush.phar /usr/bin/drush && chmod +x /usr/bin/drush
97+
98+
# Pre-trust Github host certificates.
99+
RUN ssh-keyscan github.com >> /etc/ssh/ssh_known_hosts
100+
101+
ADD templates /templates
102+
ADD scripts/* /usr/local/bin/
103+
104+
# /common-php70
105+
106+
# NodeJS + Yarn
107+
ARG NODE_MAJOR_VERSION=16
108+
RUN apt-get update \
109+
&& apt-get install -y apt-transport-https lsb-release gnupg > /dev/null 2>&1 \
110+
&& curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
111+
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
112+
&& echo "deb https://deb.nodesource.com/node_$NODE_MAJOR_VERSION.x $(lsb_release --codename | cut -f2) main" > /etc/apt/sources.list.d/nodesource.list \
113+
&& echo "deb-src https://deb.nodesource.com/node_$NODE_MAJOR_VERSION.x $(lsb_release --codename | cut -f2) main" >> /etc/apt/sources.list.d/nodesource.list \
114+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
115+
&& apt-get update \
116+
&& apt-get install -y nodejs \
117+
&& apt-get install -y --no-install-recommends yarn \
118+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
119+
120+
# XDebug
121+
RUN pecl install xdebug \
122+
&& docker-php-ext-enable xdebug \
123+
&& echo "xdebug.default_enable=0\nxdebug.coverage_enable=0" > $PHP_INI_DIR/conf.d/xdebug.ini
124+
125+
# Blackfire Probe. Note: We do not install Blackfire CLI. You will
126+
# need that in order to trigger Blackfire tests. The probe just instruments
127+
# things on the server side.
128+
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
129+
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
130+
&& mkdir -p /tmp/blackfire \
131+
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
132+
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
133+
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
134+
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
135+
136+
# Terminus.
137+
ARG TERMINUS_VERSION=2.2.0
138+
ARG TERMINUS_SHA256="73fcdf6ceee23731c20bff45f668bde09230af347670a92e5ca97c2c008ae6e0"
139+
RUN curl -fsSOL https://github.com/pantheon-systems/terminus/releases/download/$TERMINUS_VERSION/terminus.phar \
140+
&& echo "$TERMINUS_SHA256 terminus.phar" | sha256sum -c - \
141+
&& mv terminus.phar /usr/local/bin/terminus \
142+
&& chmod +x /usr/local/bin/terminus
143+
144+
# Gulp-cli.
145+
RUN npm i --no-cache -g gulp-cli
146+
147+
# ImageMagick
148+
RUN apt-get update \
149+
&& apt-get install -y imagemagick > /dev/null 2>&1 \
150+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
151+

8.0-dev/scripts/check-apache-mem

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'

8.0-dev/scripts/docker-php-entrypoint

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Write overrides to PHP and Apache. This is incompatible with starting the container
5+
# with any user other than root, but that's not advised for the PHP Apache container
6+
# anyway.
7+
dockerize \
8+
-template /templates/php.overrides.tmpl:$PHP_INI_DIR/conf.d/99-runtime.ini \
9+
-template /templates/mpm_prefork.conf.tmpl:/etc/apache2/mods-enabled/mpm_prefork.conf
10+
11+
# Toggle XDebug completely on and off at runtime
12+
# Enable Xdebug by setting XDEBUG_ENABLE=1.
13+
if [ -z "$XDEBUG_ENABLE" ] || [ "$XDEBUG_ENABLE" -eq "0" ]; then
14+
rm -f $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini
15+
else
16+
docker-php-ext-enable xdebug
17+
fi
18+
19+
# first arg is `-f` or `--some-option`
20+
if [ "${1#-}" != "$1" ]; then
21+
set -- apache2-foreground "$@"
22+
fi
23+
exec "$@"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Allow overriding some settings to control performance.
2+
<IfModule mpm_prefork_module>
3+
StartServers 5
4+
MinSpareServers 5
5+
MaxSpareServers 10
6+
MaxRequestWorkers {{ default .Env.APACHE_REQUEST_WORKERS "150" }}
7+
MaxConnectionsPerChild 5000
8+
</IfModule>

8.0-dev/templates/php.overrides.tmpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; Set a reasonable max upload size
2+
upload_max_filesize = 128M
3+
post_max_size = 128M
4+
5+
; These settings can be overridden at runtime by the presence of environment
6+
; variables.
7+
date.timezone={{ default .Env.TZ "UTC" }}
8+
{{ if .Env.PHP_MEMORY_LIMIT }}memory_limit={{ .Env.PHP_MEMORY_LIMIT }}{{ end }}
9+
{{ if .Env.SENDMAIL_PATH }}sendmail_path={{ .Env.SENDMAIL_PATH }}{{ end }}
10+
11+
; XDebug can be conditionally triggered.
12+
{{ if .Env.XDEBUG_ENABLE }}
13+
xdebug.remote_host={{ default .Env.XDEBUG_REMOTE_HOST "host.docker.internal" }}
14+
xdebug.idekey={{ default .Env.XDEBUG_IDEKEY "PHPSTORM" }}
15+
xdebug.remote_enable={{ default .Env.XDEBUG_REMOTE_ENABLE "On" }}
16+
xdebug.remote_autostart={{ default .Env.XDEBUG_REMOTE_AUTOSTART "On" }}
17+
{{ end }}

8.0-dev/test.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
schemaVersion: "2.0.0"
2+
commandTests:
3+
- name: "php should be configurable by environment variables"
4+
setup: [["docker-php-entrypoint"]]
5+
envVars:
6+
- {key: PHP_MEMORY_LIMIT, value: 512M }
7+
- {key: SENDMAIL_PATH, value: /bin/true }
8+
- {key: TZ, value: America/New_York }
9+
command: "php"
10+
args: ["-i"]
11+
expectedOutput:
12+
- memory_limit => 512M => 512M
13+
- sendmail_path => /bin/true => /bin/true
14+
- date.timezone => America/New_York => America/New_York
15+
- name: "php should use have default values"
16+
setup: [["docker-php-entrypoint"]]
17+
command: "php"
18+
args: ["-i"]
19+
expectedOutput:
20+
- memory_limit => 128M => 128M
21+
- sendmail_path => -t -i => -t -i
22+
- date.timezone => UTC => UTC
23+
- name: "Composer should work"
24+
command: composer
25+
args: ["diagnose"]
26+
- name: "Drush should be launchable"
27+
command: drush
28+
args: ["--drush-launcher-version"]
29+
expectedOutput:
30+
- "Drush Launcher Version: 0.6.0"
31+
32+
- name: "Blackfire agent should be present and configured"
33+
command: "php"
34+
args: ["-i"]
35+
expectedOutput:
36+
- Blackfire => enabled
37+
- blackfire.agent_socket => tcp://blackfire:8707 => tcp://blackfire:8707
38+
- name: "XDebug should be installed and disabled by default"
39+
command: "php"
40+
args: ["-m"]
41+
setup: [["docker-php-entrypoint"]]
42+
excludedOutput:
43+
- Xdebug
44+
- name: "XDebug should be enableable using a simple environment variable"
45+
command: "php"
46+
args: ["-m"]
47+
setup: [["docker-php-entrypoint"]]
48+
envVars:
49+
- {key: XDEBUG_ENABLE, value: True }
50+
expectedOutput:
51+
- Xdebug
52+
- name: "XDebug should be configurable by using environment variables"
53+
command: "php"
54+
args: ["-i"]
55+
setup: [["docker-php-entrypoint"]]
56+
envVars:
57+
- {key: XDEBUG_ENABLE, value: True }
58+
- {key: XDEBUG_REMOTE_HOST, value: foo.bar}
59+
- {key: XDEBUG_IDEKEY, value: foobar}
60+
- {key: XDEBUG_REMOTE_ENABLE, value: 1}
61+
- {key: XDEBUG_REMOTE_AUTOSTART, value: 1}
62+
expectedOutput:
63+
- xdebug.remote_autostart => On => On
64+
- xdebug.remote_enable => On => On
65+
- xdebug.remote_host => foo.bar => foo.bar
66+
- xdebug.idekey => foobar => foobar
67+
- name: "NodeJS Should be installed and in the correct version"
68+
command: "node"
69+
args: ["--version"]
70+
expectedOutput:
71+
- v16.
72+
- name: "Yarn should be installed and functional"
73+
command: "yarn"
74+
args: ["--version"]
75+
- name: "Terminus should be installed and functional"
76+
command: "terminus"
77+
args: ["self:info"]
78+

8.0/Dockerfile

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
FROM php:8.0-apache
2+
3+
# common-php70
4+
ENV DEBIAN_FRONTEND noninteractive
5+
ENV APACHE_DOCROOT /var/www/html
6+
ENV PATH=/var/www/vendor/bin:$PATH
7+
ENV COMPOSER_MEMORY_LIMIT "-1"
8+
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
# for bz2
11+
bzip2 libbz2-dev \
12+
# for ftp
13+
libssl-dev \
14+
# for gd
15+
libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
16+
# for intl
17+
libicu-dev \
18+
# for dom
19+
libxml2-dev \
20+
# for ldap
21+
libldap2-dev \
22+
# for mysql
23+
mariadb-client \
24+
# for ssh client only
25+
openssh-client \
26+
# For image optimization
27+
jpegoptim \
28+
optipng \
29+
pngquant \
30+
# php7.3 needs zlib1g-dev and libzip-dev for the zip extension
31+
# https://github.com/docker-library/php/issues/61#issuecomment-468874705
32+
zlib1g-dev \
33+
libzip-dev \
34+
# for git
35+
git \
36+
# for composer
37+
unzip \
38+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
39+
40+
RUN docker-php-ext-configure gd \
41+
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu \
42+
&& docker-php-ext-install -j$(nproc) \
43+
bcmath \
44+
bz2 \
45+
calendar \
46+
exif \
47+
ftp \
48+
gd \
49+
gettext \
50+
intl \
51+
ldap \
52+
mysqli \
53+
opcache \
54+
pcntl \
55+
pdo_mysql \
56+
shmop \
57+
soap \
58+
sockets \
59+
sysvmsg \
60+
sysvsem \
61+
sysvshm \
62+
zip \
63+
&& pecl install redis apcu \
64+
&& docker-php-ext-enable redis apcu
65+
66+
# Configure Apache:
67+
RUN a2enmod rewrite headers expires \
68+
&& sed -i "/DocumentRoot \/var\/www\/html/c\\\tDocumentRoot \$\{APACHE_DOCROOT\}" /etc/apache2/sites-enabled/000-default.conf \
69+
# Preemptively add a user 1000, for use with $APACHE_RUN_USER on osx
70+
&& adduser --uid 1000 --gecos 'My OSX User' --disabled-password osxuser
71+
72+
# Install Composer.
73+
74+
ARG COMPOSER_VERSION=2.3.10
75+
RUN COMPOSER_SHA384=$(curl https://composer.github.io/installer.sig) \
76+
&& curl -fsSL -o composer-setup.php https://getcomposer.org/installer \
77+
&& echo "$COMPOSER_SHA384 composer-setup.php" | sha384sum -c - \
78+
&& php composer-setup.php --version=$COMPOSER_VERSION --install-dir=/usr/local/bin --filename=composer
79+
80+
# Install Dockerize.
81+
ARG DOCKERIZE_VERSION=v0.6.1
82+
ARG DOCKERIZE_SHA256=1fa29cd41a5854fd5423e242f3ea9737a50a8c3bcf852c9e62b9eb02c6ccd370
83+
RUN curl -fsSOL https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
84+
&& echo "$DOCKERIZE_SHA256 dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz" | sha256sum -c - \
85+
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
86+
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
87+
88+
# Install Drush Launcher. Whereas previously we installed Drush globally, we no longer do,
89+
# since it's expected that D8 sites will include their own copy of Drush, and Drush 9+ is
90+
# incompatible with Drupal < 8.
91+
# @todo: Is the launcher even needed? We add /var/www/vendor/bin on the global path.
92+
ARG DRUSH_LAUNCHER_VERSION=0.6.0
93+
ARG DRUSH_LAUNCHER_SHA256=c3f32a800a2f18470b0010cd71c49e49ef5c087f8131eecfe9b686dc1f3f3d4e
94+
RUN curl -fsSOL https://github.com/drush-ops/drush-launcher/releases/download/$DRUSH_LAUNCHER_VERSION/drush.phar \
95+
&& echo "$DRUSH_LAUNCHER_SHA256 drush.phar" | sha256sum -c - \
96+
&& mv drush.phar /usr/bin/drush && chmod +x /usr/bin/drush
97+
98+
# Pre-trust Github host certificates.
99+
RUN ssh-keyscan github.com >> /etc/ssh/ssh_known_hosts
100+
101+
ADD templates /templates
102+
ADD scripts/* /usr/local/bin/
103+
104+
# /common-php70
105+

8.0/scripts/check-apache-mem

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'

0 commit comments

Comments
 (0)