/golang-docker-example

An example of how to run a Golang project in Docker in a Buildkite pipeline

Primary LanguageGoMIT LicenseMIT

Buildkite Golang Docker Example

Add to Buildkite

This repository is an example on how to test a Golang project through Docker using Buildkite.

Using in your own build pipelines

  1. Ensure docker-compose is installed on your build system. For details on how to do this, see: https://docs.docker.com/compose/install/

  2. Use our Dockerfile and docker-compose.yml files as defaults:

    cd /your/golang/repo
    curl -o Dockerfile https://raw.githubusercontent.com/buildkite/golang-golang-example/master/Dockerfile
    curl -o docker-compose.yml https://raw.githubusercontent.com/buildkite/golang-golang-example/master/docker-compose.yml
  3. Replace /go/src/github.com/buildkite/golang-docker-example in the Dockerfile and docker-compose.yml files with your own Golang import path. For example, if your import path in Golang looks like this:

    import (
      "github.com/keithpitt/project/sub-package"
    )

    Then you would replace /go/src/github.com/buildkite/golang-docker-example with /go/src/github.com/keithpitt/project (note the sub-package part of the import is not included). This path should also match the directory structure within the $GOPATH on your own development machine.

  4. Add to your build pipeline and add the BUILDKITE_DOCKER_COMPOSE_CONTAINER env:

    steps:
      - command: "./scripts/test.sh"
        env:
          BUILDKITE_DOCKER_COMPOSE_CONTAINER: "app"

License

See Licence.md (MIT)