将现有 heroku 应用程序的堆栈从 heroku-18 设置为 'container' 以获得 Docker 图像?

Set the stack for an existing heroku app from heroku-18 to 'container' for a Docker image?

我正在尝试找到一种将堆栈设置为 'container' 的方法,这样我就可以在 docker 映像而不是 heroku-18 中部署我的应用程序。这样做的原因很复杂,但却是必要的。

Heroku Docker image setup docs 说我可以在我的 app.json 文件中这样做,像这样:

"stack": "container"

但是这样做会导致通过在线界面部署时出错:

 !     No default language could be detected for this app.
            HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
            See https://devcenter.heroku.com/articles/buildpacks
 !     Push failed

还有其他方法可以将 stack 设置为 container 吗?例如,根据 these docs 也可以使用 Dockerfile 进行设置,但不清楚具体如何操作。

我知道我可以使用 heroku CLI,但我更愿意在我的 git 存储库中进行设置,因为此应用程序也会部署到其他用户。

提前感谢您的任何建议!

要使用命令行将堆栈设置为 container(作为编辑 app.json 的替代方法),我相信

heroku stack:set container

会成功的。您可以在此处阅读有关在 Heroku 上部署容器的更多信息(有关上述语法,请参阅入门的第 3 步):

https://devcenter.heroku.com/articles/build-docker-images-heroku-yml

我也遇到了同样的问题

当您创建“部署到 Heroku”按钮时,“stack: container”方法的 app.json 规范有效。 (GUI 方式)docs

https://heroku.com/deploy?template=https://github.com/user/repo 单击此 link 即可。建设成功。

但是如果按照下面的方法是行不通的:

  • 从 heroku 仪表板创建一个新应用程序
  • 转到部署选项卡

  • 连接到 github 存储库
  • 然后点击部署

只需要运行这个命令

$ heroku stack:set heroku-18 --app HEROKU_APP_NAME