Description
I'm deploying my symfony project in prod. It works fine when I simply run docker-compose up
. However I'm getting an issue with my deploy script and try accessing the web page in my navigator.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/redaph/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /var/www/redaph/vendor/composer/ClassLoader.php on line 444
What is weird is that, in my dockerfile I specify that I want my PHP_MEMORY_LIMIT to be at 256M. When I enter my container I see the following:
root@125de315edca:/var/www/redaph# php -i | grep memory_limit
memory_limit => 128M => 128M
Question
Why is my Docker Symfony project consuming so much memory?
If this is normal then: How do I correctly increase the PHP_MEMORY_LIMIT in my dockerfile?
deploy_prod.sh
#!/usr/bin/env bash
PROJECT=symfony
docker-compose up -d
docker exec redaph_symfony_1 php bin/console d:s:u --force
docker exec redaph_symfony_1 php bin/console c:c
Dockerfile:
FROM php:7.2-apache
ENV \
APACHE_ADMIN_EMAIL=webmaster@localhost \
PHP_TIME_ZONE=Europe/London \
PHP_MEMORY_LIMIT=256M \
PHP_UPLOAD_MAX_FILESIZE=32M \
PHP_POST_MAX_SIZE=32M
ARG WORK_DIR
WORKDIR $WORK_DIR
COPY composer.lock $WORK_DIR
COPY composer.json $WORK_DIR
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN apt-get update \
&& apt-get install -y -f apt-transport-https \
libicu-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libpq-dev \
acl \
cron \
git \
zip \
&& pecl install mongodb \
&& docker-php-ext-enable mongodb \
&& docker-php-ext-install \
exif \
gd \
intl \
opcache \
pdo_mysql \
pdo_pgsql \
zip \
&& curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& composer install --no-dev --prefer-dist --optimize-autoloader --no-scripts \
&& chown -R www-data:www-data $WORK_DIR \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& a2enmod rewrite \
&& service cron start