Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull environment config values from environment variables #175

Closed
regner opened this issue May 28, 2016 · 5 comments
Closed

Pull environment config values from environment variables #175

regner opened this issue May 28, 2016 · 5 comments
Assignees
Milestone

Comments

@regner
Copy link

regner commented May 28, 2016

The 12 factor app gives some good reasons for this: http://12factor.net/config

Having the config values in environment variables means only having to maintain one list of config values and not having to switch between different configs. It also makes putting the application into a Docker container a lot easier, which is what I am hoping to do. :)

@exodus4d
Copy link
Owner

Absolutely agree with you!
I´ll implement this as the new "default" in one of the next minor releases. If system vars are not set/found we use the environment.ini as fallback for those who are on a "shared hoster" or simply can´t set environment vars.
We need to add this check in here: https://github.com/exodus4d/pathfinder/blob/develop/app/main/controller/controller.php#L762

@exodus4d exodus4d self-assigned this May 28, 2016
@exodus4d
Copy link
Owner

IMPORTANT: If you have a running installation, nothing has to be changed! This is just an alternative setup feature for your environment configuration

When I´m done with my testing, I´ll push the following changes to develop branch:
  • added a panel to /setup route that shows the current environment configuration
    • the first row shows, were those configuration came from:
      • Config: environment.ini or
      • PHP: environment variables
    • environment conf vars are checked against a "white list"
    • missing vars will have a red [missing] label
    • sensitive values like secret keys, passwords,... are obscured
  • Pathfinder will automatically check for existing PHP environment variables
    • if environment variables were not found -> envinment.ini is loaded and parsed for that variables (as before)
Who should use this?
  • Anyone who uses git pull and does not want the "environment settings" (DB credentials,..) to be overwritten any time
  • Anyone who want to keep the "environment settings" independent from this installation

Environment panel

Environment variables from Config: environment.ini (fallback)
setup_environment

Environment variables from PHP environment variables (priority)
setup_environment1


Hint: All environment variables are prefixed with PF-ENV-.

Set PHP environment variable
Nginx (FastCGI)

PHP environment variables have to be passed as fastcgi_param to PHP: You should add a new *.config file to your PHP locationsection and create develop-pathfinder.conf.

location ~ \.php$ {
    try_files             $uri =404;
    include              nginx.fastcgi.conf;
    fastcgi_pass      php_farm;
    include              /var/www/environment/develop-pathfinder.conf;
}
  • restart/reload Nginx
Apache (mod_php)

You can pass all environment variables by adding them to your .htaccess.
This is not tested yet, but it should work :)

    SetEnv     PF-ENV-URL         http://www.pathfinder-w.space
    SetEnv     PF-ENV-DEBUG        3
  • restart apache

@exodus4d exodus4d added this to the v 1.0.0RC3 milestone May 28, 2016
@exodus4d exodus4d mentioned this issue Jun 3, 2016
@Tupsi
Copy link
Contributor

Tupsi commented Jun 6, 2016

this breaks the cronjobs using the prefered method A mentioned in the wiki documenation (as the cli php does not have access to the nginx env variables and falls back to what is in evironment.ini).

@exodus4d
Copy link
Owner

"TCP socket" config and CACHE backend can be set by PHP environment vars

Updated: develop-pathfinder.conf
^^ Config example for Redis cache backend.

@exodus4d
Copy link
Owner

More information about new (optional) WebSocket setup: #420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants