Skip to content

Commit 1f12d19

Browse files
committed
Fix
1 parent fc5105f commit 1f12d19

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

php-85/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ RUN set -xe; \
176176
cp php.ini-production ${INSTALL_DIR}/etc/php/php.ini
177177

178178

179-
# From PHP 8.5 opcache is enabled by default, we need to remove the `zend_extension=opcache.so` line
180-
RUN sed -i '/^zend_extension=opcache.so/d' ${INSTALL_DIR}/etc/php/php.ini
181-
182-
183179
# Install extensions
184180
# We can install extensions manually or using `pecl`
185181
RUN pecl install APCu
@@ -229,7 +225,7 @@ FROM public.ecr.aws/lambda/provided:al2023-${IMAGE_VERSION_SUFFIX} as function
229225
# We selected the files in /bref-layer, now we copy them to /opt (the real directory for the Lambda layer)
230226
COPY --link --from=build-environment /bref-layer /opt
231227

232-
COPY --link src/php.ini /opt/bref/etc/php/conf.d/bref.ini
228+
COPY --link src/php-85.ini /opt/bref/etc/php/conf.d/bref.ini
233229
COPY --link src/php-fpm.conf /opt/bref/etc/php-fpm.conf
234230

235231
COPY --link src/bootstrap.sh /opt/bootstrap

src/php-85.ini

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
; On the CLI we want errors to be sent to stdout -> those will end up in CloudWatch
2+
; In FPM workers we don't want that, but that is overridden by Bref when it starts PHP-FPM
3+
display_errors=1
4+
5+
; Since PHP 7.4 the default value is E_ALL
6+
; We override it to set the recommended configuration value for production.
7+
; See https://github.com/php/php-src/blob/d91abf76e01a3c39424e8192ad049f473f900936/php.ini-production#L463
8+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
9+
10+
memory_limit=10240M
11+
12+
opcache.enable=1
13+
opcache.enable_cli=1
14+
15+
; Store the opcodes into a file cache (on top of storing in memory)
16+
; With FPM, this is only useful if FPM restarts or if the shared memory cache is full.
17+
; With the function runtime, this is useful when the function restarts the PHP
18+
; process on every invocation.
19+
; TODO store in a subdirectory (but the problem is that the subdirectory doesn't exist when PHP starts...)
20+
opcache.file_cache="/tmp"
21+
; Disable the memory cache since it's useless
22+
; In my tests it allows to gain 30% of response time in a classic API controller
23+
opcache.file_cache_only=1
24+
; Skip this check to save a bit
25+
opcache.validate_permission=0
26+
27+
; The code is readonly on lambdas so it never changes
28+
; This setting is now disabled: code could be written to /tmp which is read/write
29+
; (e.g. a compiled container) Such a performance optimization can be done by users.
30+
;opcache.validate_timestamps=0
31+
32+
; Set sane values, modern PHP applications have higher needs than opcache's defaults
33+
; See https://tideways.com/profiler/blog/fine-tune-your-opcache-configuration-to-avoid-caching-suprises
34+
opcache.memory_consumption=128
35+
opcache.max_accelerated_files=10000
36+
37+
; This directive determines which super global arrays are registered when PHP
38+
; starts up. G,P,C,E & S are abbreviations for the following respective super
39+
; globals: GET, POST, COOKIE, ENV and SERVER.
40+
; We explicitly populate all variables else ENV is not populated by default.
41+
; See https://github.com/brefphp/bref/pull/291
42+
variables_order="EGPCS"
43+
44+
; The lambda environment is not compatible with fastcgi_finish_request
45+
; See https://github.com/brefphp/bref/issues/214
46+
disable_functions=fastcgi_finish_request
47+
48+
; The total upload size limit is 6Mb, we override the defaults to match this limit
49+
; API Gateway has a 10Mb limit, but Lambda's is 6Mb
50+
post_max_size=6M
51+
upload_max_filesize=6M
52+
53+
extension_dir=/opt/bref/extensions

0 commit comments

Comments
 (0)