• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
suggestion for a solution to development machine vs production

#1
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
Reply

#2
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
Reply

#3
(02-02-2021, 04:35 AM)craig Wrote: 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
thanks mucho!
proof that an old dog can learn new tricks
Reply

#4
(02-03-2021, 09:07 AM)richb201 Wrote:
(02-02-2021, 04:35 AM)craig Wrote: 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
thanks mucho!
BTW, I am using CI 3. Same answer?
proof that an old dog can learn new tricks
Reply

#5
(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.
Reply

#6
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
Reply

#7
https://stackoverflow.com/questions/1755...-it-in-php
Reply

#8
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
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.