Skip to content

Commit d6bb3f5

Browse files
author
Bryan Latten
committed
Merge pull request #48 from jimdelois/feature-client-max-body-size
Providing CLIENT_MAX_BODY_SIZE configuration from Downstream apps
2 parents a5781dc + c245169 commit d6bb3f5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ Applications that leverage `bryanlatten/docker-php` in their Dockerfile are expe
2626

2727
Development libraries are made available (php5-dev) for downstream app to use to add dependencies, such as PECL modules. Please run /clean.sh at the end of a child build to ensure these packages are removed before production.
2828

29+
###Downstream Configuration
30+
---
31+
Several environment variables can be used to configure various PHP FPM paramaters, as well as a few Nginx configurations. By default, all `CFG_*` environment variables are ingested by the FPM process
32+
as such. These can be used to drive the configuration of the downstream PHP application in any way necessary, but there are a few environment variables that `bryanlatter/docker-php` will process along the way...
33+
34+
Variable | Example | Description
35+
--- | --- | ---
36+
`CFG_*` | `CFG_DATABASE_USERNAME=root` | Ingested into `/etc/php5/fpm/pool.d/www.conf` for PHP to access as an environment variable
37+
`CFG_APP_DEBUG` | `CFG_APP_DEBUG=1` | Setting to `1` or `true` will cue the Opcache to watch for file changes as well as increase Nginx's default buffer sizes, suitable for Development Mode. Otherwise, headers are normal and the Opcache check is skipped for a performance boost.
38+
`SERVER_MAX_BODY_SIZE` | `SERVER_MAX_BODY_SIZE=4M` | Allows the downstream application to specify a non-default `client_max_body_size` configuration for the `server`-level directive in `/etc/nginx/sites-available/default`
39+

container/root/run.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ else
3737
echo 'opcache.validate_timestamps=0' >> /etc/php5/mods-available/opcache.ini
3838
fi
3939

40+
if [[ $SERVER_MAX_BODY_SIZE ]]
41+
then
42+
DEST_CONF_DEFAULT=/etc/nginx/sites-available/default
43+
DEST_CONF_DEFAULT_TMP=$DEST_CONF_DEFAULT.tmp
44+
45+
# Create TMP config file, omitting the closing bracket
46+
head -n -1 $DEST_CONF_DEFAULT > $DEST_CONF_DEFAULT_TMP
47+
48+
echo "Bumping client_max_body_size to $SERVER_MAX_BODY_SIZE"
49+
echo " client_max_body_size $SERVER_MAX_BODY_SIZE;" >> $DEST_CONF_DEFAULT_TMP
50+
51+
echo "}" >> $DEST_CONF_DEFAULT_TMP
52+
53+
# Move the updated config into place
54+
mv $DEST_CONF_DEFAULT_TMP $DEST_CONF_DEFAULT
55+
fi
56+
4057
echo 'Setting sensible PHP defaults'
4158
php5enmod defaults
4259

0 commit comments

Comments
 (0)