laserlemon / figaro

Simple Rails app configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any npm packages that could use the same secrets?

vfonic opened this issue · comments

I have a rails + webpacker project and I need to share some ENV vars between rails and webpacker (webpack/node).

It works great if I use 'dotenv-rails', but I prefer 'figaro' and its "use one file, never commit it and it's YAML" philosophy.

I also like ease of use of pushing ENV vars to heroku.

Is there some npm package that I can use, like 'dotenv', that will be able to read the secrets from config/application.yml? Should we build one? Maybe we could just fork 'dotenv' and have it parse YAML instead of reading in the "plain text" key=value pairs from multiple dotfiles.

What do you think?

@vfonic Figaro 2.0 (in development) adds a figaro exec command, which uses Ruby to load your Figaro configuration into ENV and then execute some other command of your choosing.

I'm not very familiar with Node.js development but figaro exec your/node/command might be interesting for that use case.

That might work!

I'm curious how it would work after deployment. 🤔
It might be a bit inconvenient to have to add figaro exec before every command. Plus, heroku is precompiling assets automatically, so, in order for this to work there, we'd have to override "assets:precompile" task to get ENV vars into webpacker/webpack. I'm not sure actually...

I'm eager to be the beta tester if that helps! :)

I'm also very open to the creation of a JS Figaro sidecar (by somebody else! 😜), although I might suggest avoiding replicating Figaro v1 at this point, in favor of v2.

@laserlemon Is there a better way to handle this please? (ie loading application.yml/figaro envs in webpack)

Also can you share more details on how to do it with figaro exec please?