如何通过app.json在Heroku上运行Docker Hub容器? [英] How can I run a Docker Hub container on Heroku via app.json?

查看:179
本文介绍了如何通过app.json在Heroku上运行Docker Hub容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为一个开源项目创建一个"Deploy to Heroku"按钮.单击按钮后,我希望Heroku从Docker Hub部署最新映像.如何通过我的 app.json 清单实现此目标?

I want to create a 'Deploy to Heroku' button for an open source project. When the button is clicked, I want Heroku to deploy the latest image from Docker hub. How can I achieve this via my app.json manifest?

app.json模式允许我设置来指定我要运行一个容器,但是使用此设置我只能通过 heroku.yml 文件从源代码构建容器.

The app.json schema allows me to set "stack": "container" to specify that I want to run a container, yet all I have been able to achieve with this setting is to build the container from source, via a heroku.yml file.

来自我的 app.json :

  "stack": "container",
  "formation": {
    "worker": {
      "quantity": 1
    }
  }

来自我的 heroku.yml :

build: 
  docker:
    worker: Dockerfile

上面的 app.json heroku.yml 文件在部署时成功从master容器构建.

The above app.json and heroku.yml files successfully build the container from master on deploy.

如何在部署时从Docker Hub撤出,而不是从源代码构建?

推荐答案

唯一的方法是拥有一个包含以下内容的Dockerfile.heroku文件:

The only way you could do this would be by having a Dockerfile.heroku file which contains:

FROM <your dockerhub image>

然后,在heroku.yml中:

build: 
  docker:
    worker: Dockerfile.heroku

通过此过程,Heroku将始终从源代码构建.但这是通过从DockerHub中提取映像,并丢弃其他所有内容来实现的.

With this process, Heroku will always build from source. But it will do so by pulling the image from DockerHub, discarding everything else.

无法使用Heroku的构建系统仅提取图像.

There is no way to use Heroku's build system to only pull an image.

这篇关于如何通过app.json在Heroku上运行Docker Hub容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆