在heroku上生产之前部署到测试服务器 [英] deploying to a test server before production on heroku

查看:150
本文介绍了在heroku上生产之前部署到测试服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我是新的,我不知道这是怎么应该的 -



我正在做一个webapp并使用heroku来托管



我想让几位开发人员在github上使用相同的代码。



我想要有2台服务器英雄 - 一个用于生产和一个用于测试(也称为分期?)



问题是我知道通过做什么 git push heroku master 从webapp文件夹将它发送到应用程序到首先设置的英雄服务器。


  1. 如何使用git从同一文件夹部署到2个不同的heroku实例?是可能/推荐吗?


  2. 当我推送github时,通常是主人,我应该有另一个分支来测试吗?


  3. 有没有办法在英雄实例之间传输应用程序?


如果有一个地方有一个推荐的部署例程为heroku和github我很乐意阅读它

解决方案

当您运行 git push heroku master 'heroku'您正在推送的远程存储库。在你的情况下,'heroku'似乎是对你的生产服务器的引用。类似地,你可能有一个'origin'远程指向github。



如果列出你的git遥控器,你可能会看到这样的东西:

 > git remote -v 
heroku git@heroku.com:heroku_app_name.git(fetch)
heroku git@heroku.com:heroku_app_name.git(push)
origin git@github.com:your_github_org / repo_name.git(fetch)
origin git@github.com:your_github_org / repo_name.git(push)

要推送到另一个heroku应用程序,您可以将该应用程序添加为新的git遥控器。

  git remote添加heroku-staging git@heroku.com:heroku_staging_app.git 

现在你应该可以推根据需要远程。

  git push origin master // push to github 
git push heroku-staging // deploy分摊
git push heroku master //部署到生产

一般来说,我建议你不应该手动推送到heroku。希望您可以持续集成服务器观察github,每当您进行更改时,都可以运行测试,只有当您的自动化测试通过时,才能部署到分段。然后,您可以手动触发CI任务,将任何提交目前正在投放到生产中(甚至自动化生产部署)。



您可以执行使用 heroku 命令行的相同配置。这也为您提供了一个很好的方式来管理您的两个英雄应用程序的环境变量和其他设置:
https://devcenter.heroku.com/articles/multiple-environments


As I am new at this, I am not sure if this is how it should be -

I am making a webapp and using heroku for hosting

I want to have several developers working on the same code on github.

I'd like to have 2 servers on heroku - one for production and one for testing(is it also called staging?)

problem is I know what by doing git push heroku master from the webapp folder it will send it to the application to the heroku server which was setup in the first place.

  1. How do I deploy to 2 different heroku instances from the same folder using git? Is it possible/ recommended?

  2. When I push to github it's usually the master, should I have another branch for test?

  3. Is there a way to transfer an app between heroku instances?

if there's a place where there is a recommended deployment routine for heroku and github I'd be happy to read it

解决方案

When you run git push heroku master 'heroku' identifies the remote repository you are pushing to. In your case 'heroku' seems to be a reference to your production server. Similarly you probably have an 'origin' remote pointing to github.

If you list your git remotes you'll probably see something like this:

> git remote -v 
heroku  git@heroku.com:heroku_app_name.git (fetch)
heroku  git@heroku.com:heroku_app_name.git (push)
origin  git@github.com:your_github_org/repo_name.git (fetch)
origin  git@github.com:your_github_org/repo_name.git (push)

To push to a different heroku app you can just add that app as a new git remote.

git remote add heroku-staging git@heroku.com:heroku_staging_app.git

Now you should be able to push to either remote as needed.

git push origin master //push to github
git push heroku-staging //deploy to staging
git push heroku master //deploy to production

In general I suggest that you should not be pushing to heroku manually. Hopefully you can have a continuous integration server watch github, run tests whenever you push changes, and deploy to staging only when your automated tests pass. You can then have a manually triggered CI task which pushes whichever commit is currently on staging to production as well (or even automate production deploys as well).

You can perform the same configuration using the heroku command line. That also gives you a good way to manage environment variables and other settings on both of your heroku apps: https://devcenter.heroku.com/articles/multiple-environments

这篇关于在heroku上生产之前部署到测试服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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