douweida2669 2014-11-10 10:12
浏览 45
已采纳

如何使用子目录中的主包将Go应用程序部署到Heroku?

I am currently trying to deploy a Go application to Heroku using wercker. Heroku expects the main.go to be at the repository root directory 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 look something like this:

web: my-server -port $PORT

I have read this article but since I'm using the wercker Go box to deploy to Heroku, I'm not sure what's the best way to configure this. Anyone that has successfully deployed a application like this?

  • 写回答

2条回答 默认 最新

  • douqi0090 2014-11-28 15:50
    关注

    You are using a file structure for your Go project, which disallows you to use godep for the build process, making it much slower.

    Given this, what you need is creating a .godir, which specifies the module name where your process lives in.

    Create a .godir file with this content:

    project/cmd/my-server
    

    And keep your Procfile as it is:

    web: my-server -port $PORT
    

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

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

    Fore more information on godep usage with the custom buildpack, check this guide out [1].

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测