使用敏感的设置信息部署到Heroku [英] Deploying to Heroku with sensitive setting information
问题描述
我将GitHub用于代码,将Heroku用于我的Rails应用程序的部署平台。
I'm using GitHub for code and Heroku for the deployment platform for my rails app.
我不想在Git下拥有敏感数据。这些数据包括数据库文件设置(database.yml)和其他一些具有秘密API密钥的文件。
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.
当我部署到heroku时,如何处理
When I deploy to heroku, how can I deal with files that are not under revision control.
当我使用Capistrano时,我可以编写一些钩子方法,但是我不知道该如何使用Heroku。
When I use Capistrano, I can write some hook methods, but I don't know what to do with Heroku.
推荐答案
对于Heroku,您需要在Git下具有 database.yml
,因为Heroku会自动
For Heroku, you'll need to have database.yml
under Git because Heroku will automatically read it and create a PostgreSQL configuration from it.
对于其他敏感信息,例如API密钥,Heroku提供了 config vars ,它们是有效的环境变量。您可以使用以下命令添加它们:
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']
请注意,可以使用 heroku
命令行程序,并且一旦设置它们便是持久的。
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
这篇关于使用敏感的设置信息部署到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!