将临时环境添加到工作流程 [英] Adding a staging environment to the workflow
问题描述
我目前有两个工作环境:Heroku上的 development
本地和 production
。
我想在Heroku上添加一个 staging
环境,以便在推送应用程序之前查看所有信息给用户。最好, staging
环境应该具有与
完成上述步骤需要哪些步骤? 首先,我喜欢这种倾向将我的heroku git远程设置为分段和生产,以便您可以轻松使用git push staging / production将其部署到其中的每一个。
- 创建一个
config / environments / staging.rb
你将拷贝`config / environments / production.rb'$ - 添加暂存数据库的database.yml条目heroku,但不能伤害)
- 备份你的.env文件(如果你有的话)
- 安装heroku-config插件
heroku插件:安装git://github.com/ddollar/heroku-config.git
- 将您的环境设置从heroku(生产服务器)
heroku config:pull --remote production
- 对.env文件进行更改,不要忘记将这些值添加到config:
RACK_ENV = staging RAILS_ENV = staging
,因此它将使用登台环境配置。
- 使用
heroku fork -a制作分段
(这些是你想要的heroku appnames而不是生产/分段)
- 执行`heroku config:push --remote staging'
- 确保将代码部署到适当的分段环境中
- 使用
你也可以阅读本教程,我想我用它开始使用heroku上的多个envs:
https://devcenter.heroku.com/articles/multiple-environments#managing-staging-and-production-configurations
I currently have two environments in which I work: development
locally and production
on Heroku.
I would like to add a staging
environment on Heroku to see that everything goes as expected before pushing the app live to users. Preferably, the staging
environment should have the exact same settings and data as the production
environment.
What are the steps needed to accomplish the above?
First the predispositions, i like to have my heroku git remotes set up as staging and production so you can easily use git push staging/production to deploy to each one of them. I'll be using that setup to explain how to make a staging env.
- create a
config/environments/staging.rb
which you will copy off `config/environments/production.rb' - add a database.yml entry for the staging database(not really needed for heroku but can't hurt)
- Backup your .env file (if you have it)
- Install heroku-config plugin by
heroku plugins:install git://github.com/ddollar/heroku-config.git
- pull your environment settings from heroku(production server) with
heroku config:pull --remote production
- make changes to the .env file and don't forget to add these values to the config:
RACK_ENV=staging RAILS_ENV=staging
so it will use the staging environment configuration. - fork a heroku environment with
heroku fork -a production staging
(those are heroku appnames you want instead of production/staging) - Do a `heroku config:push --remote staging'
- Be sure to deploy the code to staging env properly
You can also read this tutorial, i think i used it to get started with multiple envs on heroku: https://devcenter.heroku.com/articles/multiple-environments#managing-staging-and-production-configurations
这篇关于将临时环境添加到工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!