Deploying to Heroku with sensitive setting information

。_饼干妹妹 提交于 2019-12-20 19:44:18

问题


I'm using GitHub for code and Heroku for the deployment platform for my rails app.

I don't want to have sensitive data under Git. Such data include database file settings (database.yml) and some other files that have secret API keys.

When I deploy to heroku, how can I deal with files that are not under revision control.

When I use Capistrano, I can write some hook methods, but I don't know what to do with Heroku.


回答1:


For Heroku, you'll need to have database.yml under Git because Heroku will automatically read it and create a PostgreSQL configuration from it.

For other sensitive information such as API keys, Heroku provide config vars which are effectively environment variables. You can add them using:

heroku config:add KEY=value

—and access them from within your application using:

ENV['KEY']

Note that config vars can be listed, added and removed using the heroku command-line program and that once set they are persistent.

  • Heroku Config Vars documentation



回答2:


I would create a local branch, let's call it SECRET, and make the 'secret' modifications there. Commit them and DO NOT push them to github.

Now just checkout and keep working on the master branch till ready to release.

To prepare the release checkout the SECRET branch, merge the master branch into it, and push it to heroku as usual.

(BTW : I always forget to switch back to the work branch, git stash is your friend in this case)



来源:https://stackoverflow.com/questions/2963820/deploying-to-heroku-with-sensitive-setting-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!