Public | Automated Build

Last pushed: 8 months ago
Short Description
Containerized build environment for compiling and packaging a Go project.
Full Description


This is a docker image to build Go projects and docker images. The container will run:

  • go vet
  • golint
  • errcheck
  • test with race detector
  • coverage reports
  • The binary
  • Docker image

Reports are generated into the buildreport/ directory.

It is heavily inspired by:CenturyLinkLabs golang-builder.

Full qualified package

To build the project with valid package references the Go builder needs to create the GOPATH with proper directories. Which directories
these are is not in the Go source code. Options are:

Canonical Import Path

Go allows you to define it via source code comment, for example:

package main // import ""

See Canonical import paths

Glide package

The glide dependency manager allows you to define the root package of your project in it's glide.yaml configuration file.



Same with Godeps. You can define the full qualified package name in the Godeps/Godeps.json file:

    "ImportPath": "",

Default path

An alternative would be to provide a default path which works for all your projects. See the

Dependency management

The would be a good start to look how things are currently implemented. Currently supported are:

  • gpm is used for dependency management. This doesn't give you reproducable builds and comes with
    other issues. Though a lot of our projects use it therefore I support it until all our projects are migrated.
  • Official Go vendoring
  • godep which does vendoring
  • glide

Build local

You'll need a github token that you can pass to the container. It will be persisted in the .netrc for gpm to access private github repositories.

  • Build new go-builder docker image

    docker build --build-arg GITHUB_TOKEN=<your-token> -t go-builder .
  • Run container to build binary and code metrics

    docker run --rm \
    -v $(pwd):/src \
  • Run container to build docker image, binary and code metrics

    docker run --rm \
    -v $(pwd):/src \
    -v /var/run/docker.sock:/var/run/docker.sock \
    go-builder mytag

SSL Certificates

As the scratch image does not contain any SSL certificates you'd need to add them yourself.
A public bundle is available on [curl's download site] (
When you store it in your repo you can copy it in your Dockerfile to the image.
COPY ca-bundle.pem /etc/ssl/certs/ca-certificates.crt


"The time zone database needed by LoadLocation may not be present on all systems, especially non-Unix systems. LoadLocation looks in the directory or uncompressed zip file named by the ZONEINFO environment variable, if any, then looks in known installation locations on Unix systems, and finally looks in $GOROOT/lib/time/"resource
You can find a copy in $GOROOT/lib/time/
When you store it in your repo you can copy it in your Dockerfile to the image.


Other Resources

Docker Pull Command
Source Repository