【问题标题】:Managing Heroku Multiple environments with existing app使用现有应用程序管理 Heroku 多个环境
【发布时间】:2014-01-24 16:02:59
【问题描述】:

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

但是,我还有另一个应用程序,名为“MyAppLive”
我想像这样配置部署:

git 推送暂存
推送到 MyAppDev

git 推送生产
推送到 MyAppLive

我该怎么做?

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

【问题讨论】:

    标签: heroku


    【解决方案1】:

    以下是您需要遵循的步骤

    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>

    这意味着您现在可以使用git push production mastergit push staging master 将您的代码库推送到任一repo。

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

    例如。假设你会在本地建立一个临时分支;

    git push staging staging:master
    

    将您的本地暂存分支推送到暂存远程的主控。

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

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

    【讨论】:

    • 此外,这里有一篇关于这个主题的相当广泛的文章:devcenter.heroku.com/articles/multiple-environments。如果您想默认推送到暂存应用程序,一个提示是使用git config heroku.staging(让您不必每次都输入-r staging)。
    • 很好的电话 Ryan - 忘了那个。我在johnbeynon.posterous.com/… 的那个已经快两岁了!!哇时间过得真快:)
    猜你喜欢
    • 2014-04-14
    • 2012-05-16
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 1970-01-01
    • 2018-09-21
    • 1970-01-01
    • 2021-09-05
    相关资源
    最近更新 更多