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 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧