drv54591 2014-07-29 20:59
浏览 101
已采纳

在服务器上部署和构建Go应用

I'm totaly new to go (it looks fabulous btw).

So I want to build a "web-"app in go with the revel framework. The problem is I code on my mac (os : darwin, arch : amd64) and I want to deploy the app on my server (os : ubuntu 12.04, arch : amd64). I "go get" revel in local (so bin/revel it's a: Mach-O 64-bit executable) which is non executable on my server.

For now when I push (with git), I've got a post-receive script to build the app (revel build myapp /path/to/deploy). Before I've tried to "go get" revel on my server, but it failed too.

It's not working, I could understand why, but I don't have any idea how to get a workable workflow :

  1. Code on my mac
  2. Push my code (with git)
  3. Build the app on the server

PS: I've read http://blog.gopheracademy.com/auto-deploy-revel-site, http://revel.github.io/manual/deployment.html as well as articles about cross-compilation)

  • 写回答

3条回答 默认 最新

  • douying0108 2014-07-29 22:53
    关注

    I'm not sure if this helps.. but here goes..

    Your exact situation is what I am currently doing daily whilst I develop my first proper web app in Go. I develop on both a Windows laptop (whilst bored at work.. I'm a .NET developer at my workplace!) and my Mac at home. I then deploy it to an Ubuntu server hosted on Digital Ocean.

    My workflow is:

    • Make any changes.
    • Commit to repository (BitBucket)
    • Pull from repo (wherever that may be - e.g, on my Ubuntu server)
    • go build the code in place on the server
    • go get any libraries that it complains about which I don't have on the server (for example, gorilla/mux wasn't on the server today so I just ran that)
    • go build again (if applicable)

    ..then just run it on the server.

    When starting with this workflow (which I am still trying to perfect with bash scripts, etc ...) I found that a consistent GOPATH across environments really helps.

    For example, my GOPATH on each machine is:

    • Windows: C:\GOPATH
    • Mac: ~/go-code/
    • Linux: /home/simon/go-code/

    Each of them have exactly the same structure:

    • $GOPATH
      • src
        • github.com/
          • gorilla/
          • revel/
          • etc.../
        • Simon
          • WebApp1 <--- git repo
            • .git
            • src
          • WebAPp2
          • WebApp3

    ...etc. This greatly simplifies the entire thing and is what allows me to develop across 3 environments seamlessly.

    I am still getting used to Go and this setup (being a .NET developer at my core) - but it seems to be doing the trick for now.

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

报告相同问题?

悬赏问题

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