Using php.ini-production and php.ini-development -> php.ini breaks Kubernetes env vars

4/5/2020

I was reading the documentation on Docker hub and came across the:

Configuration This image ships with the default php.ini-development and php.ini-production configuration files. It is strongly recommended to use the production config for images used in production environments! I followed the steps to use them by adding the following in my Dockerfile.dev:

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

Or

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

Now when I start my cluster, all of the environmental variables it uses in the index.php say Undefined Index and the program no longer works. The fix is to comment out RUN mv... and then everything works again.

Why would it be breaking the Kubernetes environmental variables and how can I get them to work in conjunction?

-- eox.dev
docker
environment-variables
kubernetes
php

1 Answer

4/5/2020

Seems like switch from fetching environmental variables with $_ENV['<varname>'] to getenv('<varname>') fixed the issue.

-- eox.dev
Source: StackOverflow