Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: Use mpm_event and php-fpm instead of mpm_prefork and mod_php #33783

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading