diff --git a/Dockerfile b/Dockerfile index 0ec650d..4520c4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,9 @@ ENV \ XDEBUG_VERSION="-3.2.1" \ XDEBUG_REMOTE_PORT=9000 \ PHP_EXTENSION_WDDX=1 \ - PHP_OPENSSL=1 + PHP_OPENSSL=1 \ + PHP_MEMORY_LIMIT="-1" \ + PHP_USE_MEMORY_LIMIT_APACHE=true ENV CONTAINER_STARTED_LOCK=/var/lock/container.starting @@ -78,7 +80,7 @@ RUN echo "---> Adding Tini" && \ RUN echo "---> Config sudoers" && \ echo "www-data ALL = ( ALL ) NOPASSWD: ALL" >> /etc/sudoers -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer RUN echo "---> Fix permissions" \ && chown -R www-data:www-data /var/log/apache2 \ && mkdir /var/www/.composer && chown -R www-data:www-data /var/www/.composer @@ -86,13 +88,11 @@ RUN echo "---> Fix permissions" \ COPY configs/ports.conf /etc/apache2/ports.conf COPY configs/logs.conf /etc/apache2/conf-enabled/logs.conf COPY configs/php-errors.ini /usr/local/etc/php/conf.d/php-errors.ini -COPY apache-run.sh /usr/bin/apache-run -COPY ./bin /usr/bin/ +COPY configs/php-memory-limit.ini /usr/local/etc/php/conf.d/php-memory-limit.ini +COPY ./bin /usr/local/bin/ RUN chmod a+x \ - /usr/bin/apache-run \ - /usr/bin/xdebug-set-mode \ - /usr/bin/post-startup-hook + /usr/local/bin/* USER www-data @@ -100,4 +100,4 @@ WORKDIR "/var/www/html" EXPOSE 8080 9001 -CMD ["/tini", "--", "/usr/bin/apache-run"] +CMD ["apache-run"] diff --git a/apache-run.sh b/bin/apache-run similarity index 92% rename from apache-run.sh rename to bin/apache-run index bfef85e..b2501f0 100755 --- a/apache-run.sh +++ b/bin/apache-run @@ -11,6 +11,10 @@ fi sudo -E newrelic-setup sudo -E opcache-setup +if [[ ${PHP_USE_MEMORY_LIMIT_APACHE} == true ]]; then + export PHP_MEMORY_LIMIT=128M +fi + if [[ ${SESSION_HANDLER} == true ]]; then sudo rm -f /usr/local/etc/php/conf.d/session-handler.ini echo "session.save_handler = ${SESSION_HANDLER_NAME}" | sudo tee -a /usr/local/etc/php/conf.d/session-handler.ini diff --git a/configs/php-memory-limit.ini b/configs/php-memory-limit.ini new file mode 100644 index 0000000..e3712df --- /dev/null +++ b/configs/php-memory-limit.ini @@ -0,0 +1 @@ +memory_limit = ${PHP_MEMORY_LIMIT} \ No newline at end of file