4

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?

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.

From my app.json:

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

From my heroku.yml:

build: 
  docker:
    worker: Dockerfile

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

How can I pull from Docker Hub on deploy, rather than building from source?

1 Answers1

8

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

FROM <your dockerhub image>

Then, in heroku.yml:

build: 
  docker:
    worker: Dockerfile.heroku

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

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

Damien MATHIEU
  • 31,924
  • 13
  • 86
  • 94
  • Is this answer still relevant at the end of 2023? if yes how can we set dockerhub credential for our heroku pipeline ? – soung Dec 27 '22 at 03:02