How do I deploy a Go app to Heroku with the main package in a subdirectory?

I am currently trying to deploy a Go app to Heroku using wercker. Heroku expects main.go to be in the root of the repository, but if possible I would like my repository directory to look something like this.

project/
  cmd/
    my-server/
      main.go
  lib1/
  lib2/
  Procfile
  ...

      

Ideally, I would like the Procfile to look something like this:

web: my-server -port $PORT

      

I read this article , but since I am using the Go wielder window to deploy to Heroku, I'm not sure what is the best way to set it up. Anyone who has successfully deployed an application like this?

+3


source to share


2 answers


You are using a file structure for your Go project, which prevents you from using it godep

for the build process, making it much slower.

With that in mind, you need to create .godir

one that specifies the name of the module your process is in.

Create a file .godir

with this content:

project/cmd/my-server

      

And save your Procfile as it is:



web: my-server -port $PORT

      

I don't even need to mention that you need to use Go's custom buildpack: https://github.com/kr/heroku-buildpack-go.git

With this .godir

file you will be able to push and deploy your application.

For more information on using godep

with a custom buildpack, check out this tutorial [1].

[1] http://mmcgrana.github.io/2012/09/getting-started-with-go-on-heroku.html

+2


source


What worked for me

godep save ./cmd/...



Then add all the stuff to the vendor folder in the repo.

0


source







All Articles