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?
source to share
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
source to share