suggestion for a solution to development machine vs production |
I have my development environment on my ubuntu laptop and it runs in Docker. I have a staging environment in AWS and have a CICD pipe from Github up to it and it also runs in Docker. On my development environment I use ngrok to point at my laptop so that external users can reach it (for testing). Thus when I am testing I use the address "http://substantiat-survey.ngrok.io" called address a, for users to reach my machine. On the staging environment I will use the address "http://substantiat" called address b, for users to reach my AWS site.
So I need to tell my code that it should use url b when it is running on my laptop. So I was looking at Config class. But I am not sure how this would work. What I'd like to do is set an environment variable in the laptop's .htaccess with the value laptop=YES", and my code will use address b if it sees this ENV variable. This is a little bit of an issue since i don't know where .htaccess is in my bitnami apache, running on both the laptop and the aws server. But the beauty of this is that the .htaccess on the laptop and the one on the server should never be merged. I thinks! Am I making a mountain out of a molehill?
proof that an old dog can learn new tricks
That's exactly what the baseURL Config property is for.
Either use a .env file to set it, or an envrionment variable. https://codeigniter.com/user_guide/insta...nning.html https://codeigniter.com/user_guide/gener...hlight=env (02-02-2021, 04:35 AM)craig Wrote: That's exactly what the baseURL Config property is for.thanks mucho!
proof that an old dog can learn new tricks
(02-03-2021, 09:07 AM)richb201 Wrote:BTW, I am using CI 3. Same answer?(02-02-2021, 04:35 AM)craig Wrote: That's exactly what the baseURL Config property is for.thanks mucho!
proof that an old dog can learn new tricks
(02-03-2021, 11:43 AM)richb201 Wrote: BTW, I am using CI 3. Same answer? No, CI3 doesn't support .env files or environment variables for configuration natively. To do this yourself, you will need to modify your config.php file to load the values from $_ENV, $_SERVER or however else you want to add them.
I guess that is what I need to do then. How will I get the value into $_SERVER? Through .htaccess? Can you point at any directions?
proof that an old dog can learn new tricks
Thanks. I need to think about this a little. Turns out that my use of Docker means that my containers are non-root. This means that I cannot just add a .env file to the container. I am considering making them root to make my job a little easier.
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |