Skip to content

Commit

Permalink
Update settings so they use env vars (#147)
Browse files Browse the repository at this point in the history
* Add php & php-fpm config via env vars

* Add pid file location to supervisord config, moved to conf dir

* Add env vars and copying of conf files
  • Loading branch information
alexz707 committed Jan 23, 2024
1 parent 0c1adac commit 8fc8d92
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
35 changes: 28 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,37 @@ RUN set -eux; \
\
build-cleanup.sh; \
\
{ \
echo "upload_max_filesize = 100M"; \
echo "memory_limit = 256M"; \
echo "post_max_size = 100M"; \
} > /usr/local/etc/php/conf.d/20-pimcore.ini; \
\
ldconfig /usr/local/lib; \
\
sync

COPY files/conf/php/php.ini /usr/local/etc/php/conf.d/20-pimcore.ini
COPY files/conf/php-fpm/php-fpm.conf /usr/local/etc/php-fpm.d/zz-www.conf

# env php.ini
ENV PHP_MEMORY_LIMIT "256M"
ENV PHP_POST_MAX_SIZE "100M"
ENV PHP_UPLOAD_MAX_FILESIZE "100M"
ENV PHP_DISPLAY_STARTUP_ERRORS 1
ENV PHP_MAX_EXECUTION_TIME "30"
ENV PHP_ERROR_REPORTING "E_ALL"

# opcache settings
ENV OPCACHE_ENABLE 1
ENV OPCACHE_ENABLE_CLI 0
ENV OPCACHE_MEMORY_CONSUMPTION 128
ENV OPCACHE_MAX_ACCELERATED_FILES 10000
ENV OPCACHE_VALIDATE_TIMESTAMPS 1
ENV OPCACHE_CONSISTENCY_CHECKS 0

# fpm settings
ENV PHP_FPM_PM dynamic
ENV PHP_FPM_PM_MAX_CHILDREN 5
ENV PHP_FPM_PM_START_SERVERS 2
ENV PHP_FPM_PM_MAX_SPARE_SERVERS 3
ENV PHP_FPM_PM_MIN_SPARE_SERVERS 1
ENV PHP_FPM_PM_MAX_REQUESTS 10000

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_MEMORY_LIMIT -1
COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer
Expand Down Expand Up @@ -203,6 +224,6 @@ RUN set -eux; \
chmod gu+rw /var/run; \
chmod gu+s /usr/sbin/cron

COPY files/supervisord.conf /etc/supervisor/supervisord.conf
COPY files/conf/supervisord/supervisord.conf /etc/supervisor/supervisord.conf

CMD ["/usr/bin/supervisord"]
8 changes: 8 additions & 0 deletions files/conf/php-fpm/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; File overwrites the original values with environment variables
[www]
pm = ${PHP_FPM_PM}
pm.max_children = ${PHP_FPM_PM_MAX_CHILDREN}
pm.start_servers = ${PHP_FPM_PM_START_SERVERS}
pm.min_spare_servers = ${PHP_FPM_PM_MIN_SPARE_SERVERS}
pm.max_spare_servers = ${PHP_FPM_PM_MAX_SPARE_SERVERS}
pm.max_requests = ${PHP_FPM_PM_MAX_REQUESTS}
14 changes: 14 additions & 0 deletions files/conf/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
memory_limit = ${PHP_MEMORY_LIMIT}
max_execution_time = ${PHP_MAX_EXECUTION_TIME}
error_reporting = ${PHP_ERROR_REPORTING}
display_errors = ${PHP_DISPLAY_ERRORS}
display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}
post_max_size = ${PHP_POST_MAX_SIZE}
upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}

opcache.enable = ${OPCACHE_ENABLE}
opcache.enable_cli = ${OPCACHE_ENABLE_CLI}
opcache.memory_consumption = ${OPCACHE_MEMORY_CONSUMPTION}
opcache.max_accelerated_files = ${OPCACHE_MAX_ACCELERATED_FILES}
opcache.validate_timestamps = ${OPCACHE_VALIDATE_TIMESTAMPS}
opcache.consistency_checks = ${OPCACHE_CONSISTENCY_CHECKS}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
; supervisor config file

[supervisord]
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
Expand Down

0 comments on commit 8fc8d92

Please sign in to comment.