<p>I have an symfony application and three kubernetes clusters : dev, staging prod.</p>
<p>I'm using env files to set the environment. I build docker images with the right .env and deploy through kubectl. But as a matter facts, the value of APP_ENV isn't taken into account, even though the other params are (database connexion for example).</p>
<p>My staging env is set to &quot;test&quot; but composer still installs dev dependencies and logs go to /var/log/dev.log. In these log lines I also have an app_environment value which should be set to &quot;test&quot; according to the .env file. Still I find &quot;local&quot; instead.</p>
<p>What am I doing wrong ?</p>
<p>My staging .env file :</p>
<pre><code>#  * .env                contains default values for the environment variables needed by the app
#  * .env.local          uncommitted file with local overrides
#  * .env.$APP_ENV       committed environment-specific defaults
#  * .env.$APP_ENV.local uncommitted environment-specific overrides


###&gt; symfony/framework-bundle ###
APP_ENV=test
APP_SECRET=XXXXXXX
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###&lt; symfony/framework-bundle ###

###&gt; doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: &quot;sqlite:///%kernel.project_dir%/var/data.db&quot;
# For a PostgreSQL database, use: &quot;postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&amp;charset=utf8&quot;
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=postgresql://root:root@postgres:5432/dbb
###&lt; doctrine/doctrine-bundle ###

###&gt; nelmio/cors-bundle ###
#CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
CORS_ALLOW_ORIGIN=^https://my-domain.com
###&lt; nelmio/cors-bundle ###

###&gt; lexik/jwt-authentication-bundle ###
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
###&lt; lexik/jwt-authentication-bundle ###

###&gt; nzo/elk-bundle ###
ELK_APP_NAME=my-app
ELK_APP_ENVIRONMENT=test
###&lt; nzo/elk-bundle ###
</code></pre>
<p>Docker file :</p>
<pre><code>FROM php:7.4-fpm

WORKDIR /app
# Install selected extensions (git, git-flow and other stuff)
RUN apt-get update \
    &amp;&amp; apt-get install -y --no-install-recommends zlib1g-dev libpq-dev git git-flow libicu-dev libxml2-dev libzip-dev\
    &amp;&amp; docker-php-ext-configure intl \
    &amp;&amp; docker-php-ext-install intl \
    &amp;&amp; docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    &amp;&amp; docker-php-ext-install pdo pdo_pgsql pgsql \
    &amp;&amp; docker-php-ext-install zip xml \
    &amp;&amp; apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Install composer
RUN curl -sS https://getcomposer.org/installer | php &amp;&amp; mv composer.phar /usr/local/bin/composer \
    &amp;&amp; apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

COPY ./my-project/ /usr/src/my-project
COPY docker-dist/back/config/php/php.ini /usr/local/etc/php/

COPY docker-entrypoint.sh /entrypoint.sh

RUN composer install --working-dir=/usr/src/my-project

# WORKDIR is /var/www/html (inherited via &quot;FROM php&quot;)
# &quot;/entrypoint.sh&quot; will populate it at container startup from /usr/src/my-project
VOLUME /var/www/app

ENTRYPOINT [&quot;/entrypoint.sh&quot;]

CMD [&quot;php-fpm&quot;]
</code></pre>

Brice Le Roux
<p>It appears the warmup wasn't working properly.</p>
<p>I had a closer look at my docker-entrypoint and manage to run composer install and cache cleaning inside.</p>
<p>Problem solved.</p>
<p>Thanks everyone.</p>
<p>entrypoint.sh :</p>
<pre><code>set -e

cd /var/www/app

tar cf - --one-file-system -C /usr/src/myapp . | tar xf -

rm -rf var/cache var/log

composer install

php bin/console cache:clear --env=dev

chown -R www-data:www-data .

exec &quot;$@&quot;```


</code></pre>
