Marcel
Marcel

Reputation: 1594

Heroku one-click-deploy of golang application with docker

I am quite new to heroku and I want to offer people to easily install my application on their own instance via a "Deploy to heroku" button as described here https://devcenter.heroku.com/articles/heroku-button.

I've now created an app.json on my develop branch: https://github.com/scribble-rs/scribble.rs/blob/develop/app.json

{
  "name": "Scribble.rs",
  "description": "A multiplayer drawing game for the browser",
  "repository": "https://github.com/scribble-rs/scribble.rs",
  "keywords": ["game", "multiplayer", "ephemeral"]
}

However, actually testing the button by calling https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fscribble-rs%2Fscribble.rs%2Ftree%2Fdevelop will result in Heroku running the default build procedure for go-projects. However, due to the fact that the resulting binary doesn't contain the resources necessary for running the application, the app will build, but crash on startup.

In order to fix this, I'd need to instead run it with a docker-buildpack. However, I couldn't really find any documentation on this specific usecase, even though it seemed quite general. For deploying via GitHub using the GitHub-connection on the "Deploy" tab of an app, you can specify a heroku.yml, which I did: https://github.com/scribble-rs/scribble.rs/blob/develop/heroku.yml

build:
  docker:
    web: Dockerfile

However, in case of the on-click-deploy, this file seems to be ignored and what I am supposed to do instead, is to explicitly specify a buildpack via the app.json. While I've found some GitHub repositories with docker-buildpacks, I kind of dislike this solution, as I'd have to trust some random repository that could either break or vanish any moment.

What exactly is the best way to go about this problem?

Upvotes: 0

Views: 345

Answers (1)

Marcel
Marcel

Reputation: 1594

It appears you have to specify the stack inside of the app.json. This wasn't very clear by reading the docs: https://devcenter.heroku.com/articles/app-json-schema#stack

I've set this to:

"stack": "container"

Upvotes: 1

Related Questions