Go Service Deployment Strategies?

I am writing several new web services in Go.

What are some deployment strategies that I can use regardless of the target platform? For example, I am developing on a Mac, but Linux will be running on intermediate / production servers.

Are there any existing deployment tools that I can use to support Go? If not, what can I do to optimize the process?

I am using LiteIDE for development. Is there any way to connect LiteIDE to the deployment process?

+8
remote-server build ssh go deployment
source share
5 answers

Unfortunately, since Go is such a young language that does not yet exist, or at least they are hard to find. I would also be interested in developing such tools for Go.

What I discovered is that some people did it themselves, or they adapted other tools, such as Capistrano , to do this for them.

Most likely, you need to do something yourself. And you donโ€™t need to limit yourself to shell scripts - do it in Go! In fact, many of the Go tools are written in Go. You should avoid compiling on the target system, since it is usually bad practice to create build tools on your production system. Go really simplifies cross binary compilation. For example, this is how you compile for ARM and Linux:

GOARCH=arm GOOS=linux go build myapp 

One thing you could do is go to the # go-nuts freenode IRC channel or join Go to the mailing list and ask the other Gophers what they are doing.

+8
source share

Capistrano sounds like a good idea to deploy alone. You can also cross-compile, as Luke suggested. Both will work just fine.

In general, though ... I am also torn between OS X (development) and Linux (deployment), and in fact I ended up just developing in a virtual machine through VirtualBox and Vagrant. I use TextMate 2 for text editing, but installing many development tools on a Mac is just a big PITA, and I'm just more comfortable with Debian or the like running somewhere in the background. Bonus - This virtual environment can reflect a deployment environment, so I can avoid surprises when I deploy my code regardless of language.

+1
source share

I have not tried this myself, but it looks like you can cross-compile golang (either with goxc or Dave Cheney golang-crosscompile ), albeit with some caveats.

But if you need to match the environment with production, which you probably need most of the time, it is safe, as Marcin suggested.

You can find some pre-created VirtualBox images at http://virtualboxes.org/images/ , although creating one of them is quite simple.

0
source share

What can I do to optimize the process?

The idea of โ€‹โ€‹cross-compiling should be even more appealing with Go 1.5 (Q3 2015), as Dave Cheney detailed in โ€œ Cross-compiling only improved in Go 1.5 :

Before:

For successful cross-compilation you will need

  • for the target platform, if they are different from your host platform, i.e. youre on darwin / amd64 (6g), and you want to compile for linux / arm (5g).
  • A standard library for the target platform, which includes some files generated at the time your Go distribution was created.

After (Go 1.5 +):

With the plan to move the Go compiler to Go , which will be implemented in release 1.5, the first problem will be solved.

 package main import "fmt" import "runtime" func main() { fmt.Printf("Hello %s/%s\n", runtime.GOOS, runtime.GOARCH) } 

build for darwin / 386

 % env GOOS=darwin GOARCH=386 go build hello.go # scp to darwin host $ ./hello Hello darwin/386 

Or create for linux / arm

 % env GOOS=linux GOARCH=arm GOARM=7 go build hello.go # scp to linux host $ ./hello Hello linux/arm 

I am developing on a Mac, but Linux will be running on intermediate / production servers.

Given that the compiler for Go is in Go, the process of creating a Linux executable from your Mac should be simple.

0
source share

Maybe I'm a little late, but I recently wrote a blog post about how I managed to deploy Go using Capistrano, cross-compiling on my local machine.

Give it away if you're still interested: http://thread0.me/2016/03/deploy-go-with-capistrano/

-one
source share

All Articles