将临时环境添加到工作流程 [英] Adding a staging environment to the workflow

查看:164
本文介绍了将临时环境添加到工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有两个工作环境:Heroku上的 development 本地和 production



我想在Heroku上添加一个 staging 环境,以便在推送应用程序之前查看所有信息给用户。最好, staging 环境应该具有与 production 环境完全相同的设置和数据。



完成上述步骤需要哪些步骤? 首先,我喜欢这种倾向将我的heroku git远程设置为分段和生产,以便您可以轻松使用git push staging / production将其部署到其中的每一个。


  1. 创建一个 config / environments / staging.rb 你将拷贝`config / environments / production.rb'$
  2. 添加暂存数据库的database.yml条目heroku,但不能伤害)

  3. 备份你的.env文件(如果你有的话)

  4. 安装heroku-config插件 heroku插件:安装git://github.com/ddollar/heroku-config.git

  5. 将您的环境设置从heroku(生产服务器) heroku config:pull --remote production

  6. 对.env文件进行更改,不要忘记将这些值添加到config: RACK_ENV = staging RAILS_ENV = staging ,因此它将使用登台环境配置。
  7. 使用 heroku fork -a制作分段(这些是你想要的heroku appnames而不是生产/分段)

  8. 执行`heroku config:push --remote staging'

  9. 确保将代码部署到适当的分段环境中

你也可以阅读本教程,我想我用它开始使用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.

  1. create a config/environments/staging.rb which you will copy off `config/environments/production.rb'
  2. add a database.yml entry for the staging database(not really needed for heroku but can't hurt)
  3. Backup your .env file (if you have it)
  4. Install heroku-config plugin by heroku plugins:install git://github.com/ddollar/heroku-config.git
  5. pull your environment settings from heroku(production server) with heroku config:pull --remote production
  6. 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.
  7. fork a heroku environment with heroku fork -a production staging (those are heroku appnames you want instead of production/staging)
  8. Do a `heroku config:push --remote staging'
  9. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆