Environment variables in config file
See original GitHub issueI have separate config json files for dev and prod, using the format
{
"user": USER,
"password": PASSWORD,
"database": DATABASE_NAME
}
Using the command db-migrate up --config config/production.json -e prod
how would I reference USER and PASSWORD from production.json in my database.json config file?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Use environment variables in the configuration - Elastic
You can use environment variable references in the config file to set values that need to be configurable during deployment. To do this,...
Read more >Using variables in configuration files - IBM
Specify a variable in the bootstrap. · Use a defined variable in the configuration. · Use variable element in the configuration. · Use...
Read more >Application configs: files or environment variables? Actually ...
Environment variables are set by who's responsible for the deployment environment: by developer on local machines, by SRE/Administrator/DevOps ...
Read more >Want to use env variables in that config file? Well, you can ...
Meet the envsubst command With envsubst we can embed the value of environment variables inside a string that comes from the standard input....
Read more >Using Environment Variables in Nginx Config File - Baeldung
envsubst is a tool that we can use to generate an Nginx config file dynamically before the server starts. It replaces variables in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TGOlson Great to see, you have found a way that works for you and your team.
From what you’ve done I think, it would help to add a method to the programable API (there is no such API yet, but v0.10.x introduce one) that specifies a config object directly instead of parsing a file? In v0.10.x things like you have done now, are much easier, as there finally an API gets introduced that is made for the purpose of using db-migrate within another node.js module or in some automation.
Details about this are about to be documented soon, since yet there is only the instruction about the call convention over a singleton. http://db-migrate.readthedocs.org/en/latest/API/programable/
Hey fellas,
Just swinging by to say we solved our problem by wrapping calls to
db-migrate
in our build tool, Gulp. We basically load our own internal config, and then provide the environment specific db url todb-migrate
. Something like this:I omitted some setup code for brevity (if anyone wants the full solution I’d be happy to provide it). We do a little more work to wrap the tasks so you can provide options, like
up --count 2
, etc., but in general this has worked very well, without having to do much code/data duplication.Edit: in case it’s not clear, the
DATABASE_URL
environment variable is a variable that can be provided todb-migrate
. If you provide this variable, you can omit using adatabase.json
config file. (It’s not documented very well in the docs).