Skip to content

Commit 53ab6b3

Browse files
authored
Merge pull request #103 from bryanlatten/overrides-env
Dockerfile: step 2 towards non-writable FS
2 parents 3e05ece + c34bebc commit 53ab6b3

File tree

7 files changed

+27
-35
lines changed

7 files changed

+27
-35
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ENV CONF_PHPFPM=/etc/php/7.0/fpm/php-fpm.conf \
1212
PHP_FPM_MAX_REQUESTS=1024 \
1313
PHP_FPM_MIN_SPARE_SERVERS=5 \
1414
PHP_FPM_MAX_SPARE_SERVERS=128 \
15+
PHP_FPM_MEMORY_LIMIT=256M \
16+
PHP_FPM_MAX_EXECUTION_TIME=60 \
17+
PHP_FPM_UPLOAD_MAX_FILESIZE=1M \
1518
NEWRELIC_VERSION=6.7.0.174
1619

1720
# Ensure cleanup script is available for the next command
@@ -109,6 +112,8 @@ RUN sed -i "s/listen = .*/listen = 127.0.0.1:9000/" $CONF_FPMPOOL && \
109112
sed -i "s/newrelic.daemon.logfile = .*/newrelic.daemon.logfile = \"\/dev\/stdout\"/" $CONF_PHPMODS/newrelic.ini && \
110113
sed -i "s/;newrelic.loglevel = .*/newrelic.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
111114
sed -i "s/;newrelic.daemon.loglevel = .*/newrelic.daemon.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
115+
# Match FPM timeout directive with .ini max execution time
116+
sed -i "s/;*request_terminate_timeout = .*/request_terminate_timeout = \${PHP_FPM_MAX_EXECUTION_TIME}/" $CONF_FPMPOOL && \
112117
# Required for php-fpm to place .sock file into, fails otherwise \
113118
mkdir /var/run/php/ && \
114119
chown -R $NOT_ROOT_USER:$NOT_ROOT_USER /var/run/php /var/run/lock /var/log/newrelic

Dockerfile-alpine

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ENV CONF_PHPFPM=/etc/php7/php-fpm.conf \
1212
PHP_FPM_MAX_REQUESTS=1024 \
1313
PHP_FPM_MIN_SPARE_SERVERS=5 \
1414
PHP_FPM_MAX_SPARE_SERVERS=128 \
15+
PHP_FPM_MEMORY_LIMIT=256M \
16+
PHP_FPM_MAX_EXECUTION_TIME=60 \
17+
PHP_FPM_UPLOAD_MAX_FILESIZE=1M \
1518
NEWRELIC_VERSION=6.7.0.174
1619

1720
RUN echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \
@@ -133,6 +136,8 @@ RUN sed -i "s/listen = .*/listen = 127.0.0.1:9000/" $CONF_FPMPOOL && \
133136
sed -i "s/;newrelic.loglevel = .*/newrelic.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
134137
sed -i "s/;newrelic.daemon.loglevel = .*/newrelic.daemon.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
135138
sed -i 's/extension\s\?=/;extension =/' $CONF_PHPMODS/newrelic.ini && \
139+
# Match FPM timeout directive with .ini max execution time
140+
sed -i "s/;*request_terminate_timeout = .*/request_terminate_timeout = \${PHP_FPM_MAX_EXECUTION_TIME}/" $CONF_FPMPOOL && \
136141
# Required for php-fpm to place .sock file into, fails otherwise \
137142
mkdir -p /var/run/php/ /var/log/php7/newrelic && \
138143
chown -R $NOT_ROOT_USER:$NOT_ROOT_USER /var/run/php /var/log/newrelic

Dockerfile-edge

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ENV CONF_PHPFPM=/etc/php/7.1/fpm/php-fpm.conf \
1212
PHP_FPM_MAX_REQUESTS=1024 \
1313
PHP_FPM_MIN_SPARE_SERVERS=5 \
1414
PHP_FPM_MAX_SPARE_SERVERS=128 \
15+
PHP_FPM_MEMORY_LIMIT=256M \
16+
PHP_FPM_MAX_EXECUTION_TIME=60 \
17+
PHP_FPM_UPLOAD_MAX_FILESIZE=1M \
1518
NEWRELIC_VERSION=6.7.0.174
1619

1720
# Ensure cleanup script is available for the next command
@@ -113,6 +116,8 @@ RUN sed -i "s/listen = .*/listen = 127.0.0.1:9000/" $CONF_FPMPOOL && \
113116
sed -i "s/newrelic.daemon.logfile = .*/newrelic.daemon.logfile = \"\/dev\/stdout\"/" $CONF_PHPMODS/newrelic.ini && \
114117
sed -i "s/;newrelic.loglevel = .*/newrelic.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
115118
sed -i "s/;newrelic.daemon.loglevel = .*/newrelic.daemon.loglevel = \"warning\"/" $CONF_PHPMODS/newrelic.ini && \
119+
# Match FPM timeout directive with .ini max execution time
120+
sed -i "s/;*request_terminate_timeout = .*/request_terminate_timeout = \${PHP_FPM_MAX_EXECUTION_TIME}/" $CONF_FPMPOOL && \
116121
# Required for php-fpm to place .sock file into, fails otherwise \
117122
mkdir /var/run/php/ && \
118123
chown -R $NOT_ROOT_USER:$NOT_ROOT_USER /var/run/php /var/run/lock /var/log/newrelic

container/root/etc/cont-init.d/09-php-fpm.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
; Use this file to override specific defaults in the stock php.ini
2-
; NOTE: this only applies to web requests through FPM, not direct or CLI PHP instantiations
2+
; NOTE: this file only applies to web requests through FPM, not direct or CLI PHP instantiations
33

4-
memory_limit = 192M
5-
max_execution_time = 60
6-
request_terminate_timeout = 60
7-
upload_max_filesize = 1M
8-
post_max_size = 1M
4+
memory_limit = ${PHP_FPM_MEMORY_LIMIT}
5+
max_execution_time = ${PHP_FPM_MAX_EXECUTION_TIME}
6+
7+
; Important: next two values should match in order to raise upload limits
8+
upload_max_filesize = ${PHP_FPM_UPLOAD_MAX_FILESIZE}
9+
post_max_size = ${PHP_FPM_UPLOAD_MAX_FILESIZE}

container/root/run.d/09-php-fpm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ then
2121
echo '[run] adding FPM-specific overrides: Alpine-only'
2222
ln -s $CONF_FPMOVERRIDES /etc/php7/conf.d/overrides.user.ini
2323
fi
24-
24+
else
25+
echo '[run] non-web mode, bypassing FPM startup'
2526
fi

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ubuntu:
55
environment:
66
CFG_APP_DEBUG: 1
77
SERVER_LOG_MINIMAL: 1
8-
PHP_FPM_MEMORY_LIMIT: 256M
8+
PHP_FPM_MEMORY_LIMIT: 257M
99
PHP_FPM_MAX_EXECUTION_TIME: 61
1010
PHP_FPM_UPLOAD_MAX_FILESIZE: 100M
1111
SERVER_MAX_BODY_SIZE: 100M
@@ -26,7 +26,7 @@ alpine:
2626
environment:
2727
CFG_APP_DEBUG: 1
2828
SERVER_LOG_MINIMAL: 1
29-
PHP_FPM_MEMORY_LIMIT: 256M
29+
PHP_FPM_MEMORY_LIMIT: 257M
3030
PHP_FPM_MAX_EXECUTION_TIME: 61
3131
PHP_FPM_UPLOAD_MAX_FILESIZE: 100M
3232
SERVER_MAX_BODY_SIZE: 100M
@@ -47,7 +47,7 @@ edge:
4747
environment:
4848
CFG_APP_DEBUG: 1
4949
SERVER_LOG_MINIMAL: 1
50-
PHP_FPM_MEMORY_LIMIT: 256M
50+
PHP_FPM_MEMORY_LIMIT: 257M
5151
PHP_FPM_MAX_EXECUTION_TIME: 61
5252
PHP_FPM_UPLOAD_MAX_FILESIZE: 100M
5353
SERVER_APP_NAME: docker-test

0 commit comments

Comments
 (0)