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条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100