I am hoping to transition to Google Cloud Builder for building my project. The project contains numerous Docker images that I want built and pushed to Google Container Registry.
I have a Cobra CLI command that works great on Travis CI that automates linting (golint
and go vet
), formatting (gofmt
), testing (go test
), as well as other things such as automating proto compilation. The command also discovers, builds, and pushes a Docker image for each of the executables (package main
) in the repository (there are many).
I would like to transition to Cloud Builder, but its unclear to me how I would go about calling Docker from the Cobra CLI. The provided go
builder image, gcr.io/cloud-builders/go
, does not have the Docker CLI and the Docker builder image, gcr.io/cloud-builders/docker
seemingly does not have a go
runtime.
Any advice on how to setup a Cloud Builder yaml that would allow me to leverage an authenticated Docker CLI while also providing support for go would be greatly appreciated.
Intriguing question.
A Cloud Build "build" is (best) configured using a cloudbuild.yaml
file. This configuration file is a declarative definition of your CI|CD process and should form part of your source repo's, can be run on checkins etc.
Cloud Build is best thought of as a pipeline processor; it applies a series of functions (sequentially) to some inputs. Generally, the outputs (artifacts) are container images (but they need not be). Each pipeline step is manifest as a container (the image given some inputs, parameters etc.)
For this reason, while Cloud Build can be a replacement for your Travis jobs, you'll need to do some work transforming what appears to be a series of command-line steps programmatically invoked using Cobra (go
,golint
, gofmt
) into a series of equivalent containerised steps defined in YAML.
Here's the list of Google-supported containers. Because Cloud Build's unit of work is a(ny) container (image), almost anything can be used. Here's the list of community-provided images.
golint
and gofmt
aren't listed (though I assume someone has built each of them). These would be trivial for you to develop and then include in your pipeline. If you do build them, please submitting them to the community repo.
gRPC protoc
is included (link)