

A Go, Docker workflow - johannesboyne
http://blog.crowdpatent.com/a-go-docker-workflow/

======
rcarmo
That Makefile is... weird. Why issue a "make sub-target" command? Makefiles
are all about understanding dependencies, so you should actually be doing

    
    
        target: dependency
            <commands>
    

...instead of

    
    
        target:
            make dependency
            <commands>
    

Doing it this way actually breaks dependency checks. It's just plain wrong.

Here's a "proper" Makefile, complete with conditionals, expansion, etc.:

[https://github.com/rcarmo/sushy/blob/master/Makefile](https://github.com/rcarmo/sushy/blob/master/Makefile)

...and here's one of my Go Makefiles (no sub-targets here, but does vendoring
in a way that's quite similar to what Go 1.5 turned out to adopt)

[https://github.com/rcarmo/go-
rss2imap/blob/master/Makefile](https://github.com/rcarmo/go-
rss2imap/blob/master/Makefile)

(edit: whitespace)

~~~
austinpray
One thing to point out specifically about "proper" Makefiles: the author
should be marking his `.PHONY` targets
([https://www.gnu.org/software/make/manual/html_node/Phony-
Tar...](https://www.gnu.org/software/make/manual/html_node/Phony-
Targets.html)) and giving sources. This gives you incremental builds for free.

One of my Makefiles: [https://github.com/liveplant/liveplant-
server/blob/master/Ma...](https://github.com/liveplant/liveplant-
server/blob/master/Makefile)

Definitely open to feedback on the above. Seems like my Makefile doing pretty
much the same thing as yours @rcarmo.

~~~
rcarmo
good call on the .PHONY.

------
olalonde
Worth checking out docker-compose for more complex setups (if you need a Redis
and PostgreSQL database running for example). I have been using it for Node.js
development for the past few months and it is really a life changer especially
if you are working on multiple projects concurrently. Pro-tip: `echo "alias
dc=docker-compose" >> ~/.zshrc`

~~~
johannesboyne
Has one of you tried xhyve? [https://coreos.com/blog/coreos-and-xhyve-tech-
preview/](https://coreos.com/blog/coreos-and-xhyve-tech-preview/)

~~~
olalonde
Haven't heard but thanks for pointing out. It might be pretty useful actually
as I develop on OS X and use CoreOS in production.

~~~
johannesboyne
And if it is faster than boot2docker with VirtualBox, great!

------
vieux
Why "FROM tianon/true" ? "FROM scratch" would be even smaller. That's what we
use in the docker swarm image: [https://github.com/docker/swarm-library-
image/blob/master/Do...](https://github.com/docker/swarm-library-
image/blob/master/Dockerfile)

------
keegancsmith
An improvement I'd make to this is not sending the current directory to
docker, but rather a directory containing just the binary. That way you don't
send a massive context to docker which you just throw away. (Especially in go
projects which vendor in a lot of dependencies)

