Yes, it’s a building a docker image with Google Cloud Build using sources (Dockerfile, etc.) from git. Long story short, we will pull the docker file and related sources from git, build the images and then put it on (Google) Container Registry.
steps:
- name: 'gcr.io/cloud-builders/git:latest'
args: ['clone', 'https://github.com/IBM/CodeEngine.git']
dir: '/staging'
volumes:
- name: staging
path: '/staging'
- name: 'gcr.io/cloud-builders/docker:latest'
args: ['build', '-t', 'gcr.io/my-project/hello-world:latest', '/staging/CodeEngine/helloworld/']
volumes:
- name: staging
path: '/staging'
images: ['gcr.io/my-project/hello-world:latest']
timeout: 600s
In the example above I’m using IBM CodeEngine’s repository and use its Hello World example. This is a fairly simple step which basically:
- Git clone from a public repository
- Build and push the image to your own registry
I’m mounting a volume called “staging” on the “/staging” path in both containers to pass the cloned repository contents. Container? Yes, as we can observe on the build configuration above, Cloud Build basically starts a container on each step. You can also use your own image to be used in Cloud Build, like maybe you need to execute CMake, npm, go, etc. after repository cloning and before building the image.
For more information, you can read the entire Cloud Build documentation here.