Skip to content

Commit

Permalink
docker: Use mpm_event and php-fpm instead of mpm_prefork and mod_php (#…
Browse files Browse the repository at this point in the history
…33783)

The main hope here is that using mpm_event rather than mpm_prefork will
make our E2E tests run better.

But mod_php is not compatible with mpm_event. The modern way to do
things is to use php-fpm instead.

And while we're at it, we may as well enable apache's http2 module too.
Although actually making effective use of that may take more work (if
anyone cares), since HTTP/2 likes to run with TLS but our dev
environment doesn't do TLS.
  • Loading branch information
anomiex authored Nov 2, 2023
1 parent 6aa0f85 commit 0340106
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN --mount=type=cache,target=/var/lib/apt/lists/,sharing=private \
&& add-apt-repository ppa:ondrej/php \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& apt-get update \
&& apt-get install -y \
&& apt-get --purge install -y \
apache2 \
git \
jq \
Expand All @@ -38,21 +38,23 @@ RUN --mount=type=cache,target=/var/lib/apt/lists/,sharing=private \
ssmtp \
subversion \
sudo \
systemd-standalone-tmpfiles \
unzip \
vim \
zip \
&& apt-get remove --purge --auto-remove -y gpg software-properties-common \
&& find /var/ -name '*-old' -delete && rm -rf /var/log/dpkg.log /var/log/alternatives.log /var/log/apt/ ~/.launchpadlib

# Enable mod_rewrite in Apache.
RUN a2enmod rewrite
# Enable various Apache modules.
RUN a2dismod mpm_prefork && a2enmod rewrite mpm_event proxy_fcgi http2

# Install requested version of PHP.
COPY ./config/php.ini /var/lib/jetpack-config/php.ini
RUN --mount=type=cache,target=/var/lib/apt/lists/,sharing=private \
--mount=type=bind,source=./bin/ensure-php-version.sh,target=/usr/local/bin/ensure-php-version.sh \
: "${PHP_VERSION:?Build argument PHP_VERSION needs to be set and non-empty.}" \
&& ensure-php-version.sh "$PHP_VERSION" \
&& a2enconf "php$PHP_VERSION-fpm" \
&& find /var/ -name '*-old' -delete && rm -rf /var/log/dpkg.log /var/log/alternatives.log /var/log/apt/ ~/.launchpadlib

# Install requested version of Composer.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/bin/ensure-php-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export DEBIAN_FRONTEND=noninteractive

# Determine packages to install.
PKGS=(
"libapache2-mod-php${VER}"
"php${VER}"
"php${VER}-bcmath"
"php${VER}-cli"
"php${VER}-curl"
"php${VER}-fpm"
"php${VER}-intl"
"php${VER}-ldap"
"php${VER}-mbstring"
Expand Down
4 changes: 4 additions & 0 deletions tools/docker/bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set -e
# If you modify anything here, remember to build the image again by running:
# jetpack docker build-image

source /etc/docker-args.sh

user="${APACHE_RUN_USER:-www-data}"
group="${APACHE_RUN_GROUP:-www-data}"

Expand Down Expand Up @@ -133,5 +135,7 @@ echo "Open http://${WP_DOMAIN}${WP_HOST_PORT}/ to see your site!"
echo

# Run apache in the foreground so the container keeps running
echo "Running php-fpm"
"/etc/init.d/php${PHP_VERSION}-fpm" start
echo "Running Apache in the foreground"
apachectl -D FOREGROUND

0 comments on commit 0340106

Please sign in to comment.