A CI compatible Go container for Docker

Thu Jan 7, 2016

These are roughly 300 words, you could read this in about 1 minutes.

Learn how to build Go apps on multiple Go versions in DroneCI.

For a few months I now I am heavily relying on Docker and DroneCI for continuous builds of my projects.

Two months ago I decided I should try out Go, and checked out the Docker Hub for official Go images, and yes they exists but sadly they only contain Go, but none of the version control systems required for go get to pick up dependencies.

The Go containers

The Go containers are available now on Docker Hub and include the official Go 1.5 or 1.6 releases, and have tags for 1.5 and 1.6. The latest tag will always point the the current stable Go release.

To supplement the go get functionality of picking up dependencies, each image also contains

docker pull danielsreichenbach/golang:1.5 will give you a Go 1.5 build environment, and docker pull danielsreichenbach/golang:1.6 (obviously) will provide a Go 1.6 environment.

Now I can e.g. execute builds in DroneCI like this:

File: .drone.yml
clone: depth: 1 build: image: danielsreichenbach/drone-golang:$$GO_VERSION commands: - go get -t -v ./... - go test -v ./ - go build -v ./ matrix: GO_VERSION: - 1.5 - 1.6

Thanks to the availability of DroneCIs CLI you can also use this locally by running drone exec in a directory containing the .drone.yml file.

Tagged with: Docker Go Continuous Integration

All code snippets in this post are made available to use under the MIT Licence.


comments powered by Disqus