Sign inSign up

dbainbriciena/go-builder

By dbainbriciena

•Updated over 8 years ago

a

Image
0

279

dbainbriciena/go-builder repository overview

⁠golang-builder

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 "github.com/alpe/ci-example-project"

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.

package: github.com/alpe/ci-example
import:
...

⁠Godeps

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

{
    "ImportPath": "github.com/alpe/ci-example",
    ...
}
⁠Default path

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

⁠Dependency management

The build_environment.sh 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 \
  go-builder
  • 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
⁠Other Resources

Tag summary

Content type

Image

Digest

Size

400.9 MB

Last updated

over 8 years ago

docker pull dbainbriciena/go-builder