-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Draft] Add mpm_event / FPM support to apache variant #785
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f1f89cb
Add FPM to apache variant
mildsunrise 1e2a3b1
Create entrypoint that starts Apache + FPM
mildsunrise 3b46f66
Move apache-fpm into script
mildsunrise 74d24f8
Run FPM with same user as Apache (by default)
mildsunrise 6c52a7a
Pass arguments directly to Apache for compatibility
mildsunrise a28a7c7
Explain things better
mildsunrise File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,50 @@ | ||
COPY apache2-foreground /usr/local/bin/ | ||
WORKDIR /var/www/html | ||
|
||
# Set up FPM | ||
RUN set -ex \ | ||
&& cd /usr/local/etc \ | ||
&& if [ -d php-fpm.d ]; then \ | ||
# for some reason, upstream's php-fpm.conf.default has "include=NONE/etc/php-fpm.d/*.conf" | ||
sed 's!=NONE/!=!g' php-fpm.conf.default | tee php-fpm.conf > /dev/null; \ | ||
cp php-fpm.d/www.conf.default php-fpm.d/www.conf; \ | ||
else \ | ||
# PHP 5.x doesn't use "include=" by default, so we'll create our own simple config that mimics PHP 7+ for consistency | ||
mildsunrise marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mkdir php-fpm.d; \ | ||
cp php-fpm.conf.default php-fpm.d/www.conf; \ | ||
{ \ | ||
echo '[global]'; \ | ||
echo 'include=etc/php-fpm.d/*.conf'; \ | ||
} | tee php-fpm.conf; \ | ||
fi \ | ||
&& { \ | ||
echo '[global]'; \ | ||
echo 'error_log = /proc/self/fd/2'; \ | ||
echo; echo '; https://github.com/docker-library/php/pull/725#issuecomment-443540114'; echo 'log_limit = 8192'; \ | ||
echo; \ | ||
echo '[www]'; \ | ||
echo 'clear_env = no'; \ | ||
echo; \ | ||
echo '; Ensure worker stdout and stderr are sent to the main error log.'; \ | ||
echo 'catch_workers_output = yes'; \ | ||
echo 'decorate_workers_output = no'; \ | ||
} | tee php-fpm.d/docker.conf \ | ||
&& { \ | ||
echo '[global]'; \ | ||
echo 'daemonize = no'; \ | ||
echo; \ | ||
echo '[www]'; \ | ||
echo 'user = ${FPM_RUN_USER}'; \ | ||
echo 'group = ${FPM_RUN_GROUP}'; \ | ||
echo 'listen = /var/run/php-fpm/fpm.sock'; \ | ||
echo 'listen.mode = 666'; \ | ||
} | tee php-fpm.d/zz-docker.conf \ | ||
&& mkdir -p /var/run/php-fpm \ | ||
# allow running as an arbitrary user | ||
&& chmod 777 /var/run/php-fpm | ||
|
||
# Provide alternate command to start Apache with FPM | ||
COPY apache-fpm /usr/local/bin/ | ||
|
||
EXPOSE 80 | ||
CMD ["apache2-foreground"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# By default, FPM will run as the same user as Apache | ||
. "$APACHE_ENVVARS" | ||
: ${FPM_RUN_USER:=$APACHE_RUN_USER} | ||
: ${FPM_RUN_GROUP:=$APACHE_RUN_GROUP} | ||
export FPM_RUN_USER FPM_RUN_GROUP | ||
|
||
# Strip off any '#' symbol ('#1000' is valid syntax for Apache) | ||
pound='#' | ||
FPM_RUN_USER="${FPM_RUN_USER#$pound}" | ||
FPM_RUN_GROUP="${FPM_RUN_GROUP#$pound}" | ||
|
||
# Setup Apache modules and launch! | ||
if [ -z "$APACHE_KEEP_MODS" ]; then | ||
a2dismod -q mpm_prefork php7 && a2enmod -q mpm_event proxy_fcgi || exit 1 | ||
fi | ||
php-fpm $FPM_ARGS & | ||
apache2-foreground -DFPM "$@" & | ||
|
||
# Wait until container is stopped, or a process crashes | ||
trap "stopped=1" TERM INT | ||
wait -n | ||
|
||
# Tell processes to terminate | ||
kill %1 %2 2> /dev/null | ||
# If there was a crash, container fails immediately | ||
if [ -z "$stopped" ]; then exit 2; fi | ||
# If the container was stopped, wait for processes to finish | ||
until wait; do true; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| tee php-fpm.conf > /dev/null
seems super pointless, just redirect to> php-fpm.conf
directly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! These lines were copied directly from the current FPM dockerfile.
I think these corrections should be done there first, in order to not maintain different versions of the snippet.