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

Allow customization of FPM settings via PHP_FPM_OVERRIDE #36

Merged
merged 1 commit into from
Aug 16, 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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ RUN chmod +x /*.sh

# Configure PHP and PHP-FPM
ADD files/php.ini /usr/local/etc/php/conf.d/zz-01-custom.ini
ADD files/php-fpm-www.conf /usr/local/etc/php-fpm.d/www.conf

ENTRYPOINT [ "/entrypoint.sh" ]
# Override CMD too (see https://github.com/moby/moby/issues/5147)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Application root is `/app`. Application runs as user `application` (uid=1000).
| `SSH_PRIVATE_KEY` | ssh | | A SSH private key to load in an `ssh-agent`, useful if you run a SSH container with commands | |
| `ENV` | ssh | | The name of the environment to show on the shell prompt |
| `PHP_INI_OVERRIDE` | fpm, ssh | | Allow overriding php.ini settings. Simply the multiline content for a php.ini here. Use "\n" for multiline i.e. in ECS |
| `PHP_FPM_OVERRIDE` | fpm | | Allow overriding php-fpm pool settings. The multiline content for php-fpm.conf here. Use "\n" for multiline i.e. in ECS |

## Example usage

Expand Down
4 changes: 2 additions & 2 deletions example-app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ services:
- example-app.vm

php:
image: croneu/phpapp-fpm:php-7.4
image: croneu/phpapp-fpm:php-8.1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not intended for this PR, but the upgrade in the example is ok...

env_file:
- '.env.docker'
- '.env'
volumes:
- app:/app

ssh:
image: croneu/phpapp-ssh:php-7.4-node-16
image: croneu/phpapp-ssh:php-8.1-node-16
ports:
- '1122:22'
volumes:
Expand Down
27 changes: 27 additions & 0 deletions files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,32 @@
# Override some PHP settings
. /entrypoint-extras.sh

PHP_FPM_POOL_CONF=/usr/local/etc/php-fpm.d/www.conf

# Configure FPM, first the defaults:
cat <<EOF > $PHP_FPM_POOL_CONF
[www]
user = application
group = application
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /status
EOF

# Allow overriding this with settings coming from PHP_FPM_OVERRIDE
if [ ! -z "${PHP_FPM_OVERRIDE}" ]; then
echo "* Customizing FPM with PHP_FPM_OVERRIDE:"
echo "- - - 8< - - -"
echo "${PHP_FPM_OVERRIDE}" | sed -e 's/\\n/\n/g'
echo "- - - 8< - - -"
echo "# Customizations from PHP_FPM_OVERRIDE:" >> $PHP_FPM_POOL_CONF
echo "${PHP_FPM_OVERRIDE}" | sed -e 's/\\n/\n/g' >> $PHP_FPM_POOL_CONF
fi


# Start the "real" entrypoint
. /usr/local/bin/docker-php-entrypoint
Loading