A CI Compatible Go container for Docker

Jan 7, 2016 00:00 · 266 words · 2 minutes read continuous integration development docker go

For a few months I now, I have been 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.

Two months ago I decided to try out Go. I checked out Docker Hub for official Go images, and while they do exist, they only contain Go and none of the version control system required for ‘go get’ to pick up the dependencies.

The Go Containers

The Go containers are available now on Docker Hub and include the official Go stable releases, and have tags starting with version 1.9.

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

  • bzr,
  • git,
  • mercurial

docker pull kogitoapp/golang:1.10 will give you a Go 1.10 build environment, and docker pull kogitoapp/golang:1.11 will provide a Go 1.11 environment.

All tagged releases also come with dep, the Go dependency management tool. Starting with Go 1.11, you can pass GO111MODULE=on as environment variable to the build to enable Go modules.

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

clone:
  depth: 1

build:
  image: kogitoapp/golang:${GO_VERSION}
  commands:
    - go get -t -v ./...
    - go test -v ./
    - go build -v ./

matrix:
  GO_VERSION:
    - 1.10
    - 1.11

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.

Comments powered by Disqus