【问题标题】:Is this the right way to run a `release` command for a Heroku Review app?这是为 Heroku Review 应用程序运行“发布”命令的正确方法吗?
【发布时间】:2020-01-03 07:01:23
【问题描述】:

我正在尝试在 Heroku 上配置评论应用。对于每个 PR,我想部署和构建 Dockerfile,然后运行我的迁移命令。

通过以下配置,Dockerfile 可以正常部署,并且应用程序似乎可以按预期工作。

Docker 文件:

FROM hasura/graphql-engine:v1.0.0-beta.4
ENV HASURA_GRAPHQL_ENABLE_CONSOLE=true
CMD graphql-engine \
    --database-url $DATABASE_URL \
    serve \
    --server-port $PORT

heroku.yml

build:
  docker:
    web: Dockerfile

app.json

{
  "name": "my_project",
  "formation": {
    "web": {
      "quantity": 1,
      "size": "free"
    }
  },
  "addons": [
    {
      "plan": "heroku-postgresql:hobby-dev",
      "options": { "version": "9.6" }
    }
  ],
  "scripts": {},
  "buildpacks": [],
  "stack": "container"
}

但是,当我添加(我认为是)用于迁移的发布脚本时,构建失败。

带有发布脚本的heroku.yml:

release:
  image: Dockerfile
  command:
    - cd ./migrations && ./hasura migrate apply --endpoint $(heroku info -s | grep web_url | cut -d= -f2)

这会导致构建错误:

=== Fetching app code...
=!= Couldn't find the release image configured for this app. Is there a matching run process?

我还尝试将release 键添加到app.json 中的scripts 键,但这似乎没有任何作用。

【问题讨论】:

  • image: Dockerfile改成image: web看看能不能用?
  • 你找到答案了吗?我也在使用 Hasura 并遇到同样的问题,建议的答案都不适合我

标签: heroku devops hasura


【解决方案1】:

image 参数不应是 Dockerfile 的名称。它应该是您构建的另一个图像。

在你的情况下,你只有一个:

web: Dockerfile

所以你需要像这样指定你的发布流程类型:

release:
  image: web
  command:
    - cd ./migrations && ./hasura migrate apply --endpoint $(heroku info -s | grep web_url | cut -d= -f2)

给你完整的heroku.yml如下:

build:
  docker:
    web: Dockerfile
release:
  image: web
  command:
    - cd ./migrations && ./hasura migrate apply --endpoint $(heroku info -s | grep web_url | cut -d= -f2)

有关更多信息,您可以查看 Heroku 官方文档:https://devcenter.heroku.com/articles/build-docker-images-heroku-yml#release-configuring-release-phase

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-16
    • 2012-12-19
    • 2015-05-06
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多