![]() |
.env and Docker Container Environment - potential problems - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: .env and Docker Container Environment - potential problems (/showthread.php?tid=78375) |
.env and Docker Container Environment - potential problems - tgix - 01-11-2021 Just a sanity-check to see if I am missing something. In a recent project I packaged a CI4 application into a Docker (php:7.3.26-apache-stretch image) and uploaded it to AWS FARGATE. In the application I use .env to configure stuff like database settings: PHP Code: database.default.hostname = localhost After googling around I came to the conclusion that it is a combination of issues here but the main culprit is the bash-shell (which Ubuntu is using, which is the base of the Docker image) defining variable names as strictly alphanumeric and underscore - dot is not allowed! The work-around I have now is to use legal variable names and then in app/Config/Database.php::__construct() do this: PHP Code: if (getenv('DATABASE_HOSTNAME')) { My question now - is there a better way? /Mattias Ah, and by the way: I also ran into another problem for some reason, variables return the wrong value using getenv() - https://github.com/codeigniter4/CodeIgniter4/issues/3992 RE: .env and Docker Container Environment - potential problems - kenjis - 01-19-2021 Unfortunately it seems there is no better way. |