In this article, I will give an introduction to Google Container Builder which satisfies these requirements.
Google Cloud Container BuilderTo access the service from your terminal using
gcloud(which is part of the Cloud SDK), you first need to enable the API. Find the Google Cloud Container Builder API in the API Manager and click enable. Also don’t forget to authenticate with
gcloud auth login.
Specifying the build stepsCreating a specification on what to build can be done in multiple ways, in this example we use a yaml file in our project. See the example cloudbuild.yaml that I’ve created for the apn repository.
The example configuration only has two steps, both which runs pre-built images provided by Google. The first step builds our binary using Go, where the second runs docker to build our final image. Our Dockerfile specification uses the
COPYcommand to add the binary created from the first step.
If you have cloned the example repository, it’s possible to manually submit this build configuration by running:
This will start the build process as soon as possible and tag the image in your container registry.
gcloud container builds submit . --config cloudbuild.yaml
Build triggersHaving a way to submit a cloudbuild configuration and see its progress live in the terminal is great, but you can also define triggers that will automatically run the build process when there are new commits.
These requires additional authentication and can be configured in Build triggers on the console.
Last wordsBeing able to provide any image to run as a build step gives you a lot of flexibility to create your own type of pipelines. You could potentially run tests and automatically deploy upon success, essentially create your own lightweight CI/CD system.
When switching the build process, the image size for the example project resulted in 6MB compared to 347MB.