【问题标题】:Specify Postgres database plan in Heroku review apps在 Heroku 评论应用程序中指定 Postgres 数据库计划
【发布时间】:2020-06-28 16:28:03
【问题描述】:

我正在尝试使用 Heroku 评论应用程序来测试我的网站并向我的同事展示。该站点有一个大型数据库,无法与 Heroku 的免费 hobby-dev 数据库一起使用。

我正在尝试使用app.json 清单文件来指定我的应用程序的平台,如the guide。我正在使用的代码如下:

app.json

  {
    "name": "SiteName",
    "description": "The website for SiteName",
    "keywords": [
      "mezzanine",
      "django"
    ],
    "image": "heroku/python",
    "env": {
      "EMAIL_SYSTEM": {
        "description": "The email system to use, either console or mailgun",
        "value": "mailgun"
      },
      "ENVIRONMENT": {
        "description": "The dev environment, either production or test",
        "value": "production"
      },
      "ALLOWED_HOSTS": {
        "description": "Comma-separated list of hosts",
        "value": ".herokuapp.com"
      },
      "DEFAULT_FROM_EMAIL": "noreply@example.com",
      "SECRET_KEY": {
        "description": "A secret key for verifying the integrity of signed cookies.",
        "generator": "secret"
      },
      "WEB_CONCURRENCY": {
        "description": "The number of processes to run.",
        "value": "5"
      },
      "NODE_ENV": "production",
      "DEBUG": "False",
      "NPM_CONFIG_PRODUCTION": "false",
      "CELERY_REDIS_MAX_CONNECTIONS": 3,
      "S3_BUCKET": "my-s3-bucket",
      "USE_CELERY_TASKS": "True"
    },
    "formation": {
      "web": {
        "quantity": 1,
        "size": "Standard-1X"
      },
      "worker": {
        "quantity": 1,
        "size": "Standard-1X"
      }
    },
    "addons": [
      "heroku-redis",
      {
       "plan": "heroku-postgresql:standard-0",
        "as": "DATABASE"
      }
    ],
    "buildpacks": [
      {
        "url": "https://github.com/heroku/heroku-buildpack-python.git"
      }
    ],
    "scripts": {
      "postdeploy": "python manage.py migrate && python manage.py populate_db"
    },
    "environments": {
      "test": {
        "addons": [
          "heroku-postgresql:in-dyno",
          "heroku-redis:in-dyno"
        ],
        "env": {
          "APP_SKIP_DB_TEARDOWN": "True",
          "DB_REQUIRE_SSL": "False",
          "DEBUG": "True",
          "S3_BUCKET": "my-s3-bucket",
          "USE_CELERY_TASKS": "False"
        },
        "scripts": {
          "test-setup": "python manage.py collectstatic --noinput",
          "test": "python manage.py test"
        }
      }
    }
  }

这样可以构建,但我如何明确指定我希望使用的数据库计划?

【问题讨论】:

  • 试试不带as键的{"plan": "heroku-postgresql:standard-0"}
  • 看起来是正确的。当您启动评论应用程序时,您会看到什么行为?错误的数据库层?错误?
  • @RangerRanger:我希望数据库属于 Standard-0 层,而不是我只得到一个 hobby-dev 层数据库。
  • 您有信用卡吗?我想知道它是否出于付款原因默认免费。否则,可以尝试使用除DATABASE 之外的其他值作为附件。 DATABASE 配置变量周围有一些默认行为可能会导致问题。
  • @TinNguyen,试过了,结果一样,只是一个爱好级别的数据库

标签: heroku heroku-postgres heroku-review-app


【解决方案1】:

以防万一其他人遇到这种情况。

根据 heroku 支持,他们已经更改了配置插件以供审查和 CI 应用程序的方式,这意味着默认情况下,无论您的 app.json Here are some details and explanation of their reasoning 中有什么内容,他们只会提供免费/最便宜的计划。

如果您打开工单,他们可以在帐户级别覆盖此设置(在撰写本文时,这似乎并未内置到他们的管理区域中)

【讨论】:

    【解决方案2】:

    您只需要使用 sintax 指定计划: heroku-postgresql:

    "addons": [
            {
              "plan": "heroku-postgresql:<plan_you_select>",
              "as": "DATABASE"
            }
     ]
    

    有关可用计划的列表,请查看此链接: https://devcenter.heroku.com/articles/heroku-postgres-plans#hobby-tier

    您也可以使用此链接:https://elements.heroku.com/addons/heroku-postgresql 在上面选择一个计划,您将在 CLI 上看到计划名称

    【讨论】:

      猜你喜欢
      • 2016-08-24
      • 2013-03-08
      • 1970-01-01
      • 2021-04-14
      • 1970-01-01
      • 2012-10-31
      • 2023-03-19
      • 2021-07-04
      • 1970-01-01
      相关资源
      最近更新 更多