使用现有应用程序管理Heroku多个环境

时间:2012-04-20 18:29:18

标签: heroku

我有一个应用程序,它将'heroku'配置为远程,一个应用程序 我们将此应用称为“MyAppDev”

但是,我有另一款名为“MyAppLive”的应用 我想配置这样的部署:

  

git push staging
  推送到MyAppDev

     

git push production
  推送到MyAppLive

我该怎么做?

另外,环境变量怎么样? 这两个应用都有MongoLab,所以我希望MyAppDev应用使用它自己的数据库....

1 个答案:

答案 0 :(得分:13)

以下是您需要遵循的步骤

  1. git remote rm heroku - 这将从您的应用程序中删除heroku远程

  2. git remote add production <production apps heroku git repo url> - 这将添加一个名为'production'的新远程指向生产应用程序git repo url(您可以从heroku.com上的我的应用程序页面获取此内容

  3. git remote add staging <staging apps heroku git repo url>

  4. 这意味着您可以执行git push production mastergit push staging master将代码库推送到任一仓库。

    注意如果你需要将分支推送到Heroku,你需要将它们推入Heroku的主分支。

    例如。在本地假设一个临时分支,你会这样做;

    git push staging staging:master
    

    将本地登台分支推送到登台遥控器的主控。

    您使用的任何插件都需要复制到登台应用程序。

    配置变量可以通过heroku config:set手动完成,也可以使用本页底部详述的插件https://devcenter.heroku.com/articles/config-vars,它允许您将Heroku变量推送到适合的.env文件中在本地与Foreman一起运行。尽管可以覆盖变量 - 我倾向于手动执行变量,因为我通常没有很多变量。

相关问题