As part of the process of setting up a blog and deploying it on Google Cloud, I wanted to set up a full CI/CD pipeline using Google Cloud services. It is surprisingly easy to do so. This is a short tutorial on a basic automation setup leveraging Google Cloud Services, GitHub and Docker.
Create Service
Continuously deploy new revision from a source repository
Enable Cloud Build API
Note
Cloud Build is a service designed to handle a variety of code compilation scenarios. It has its own configuration language and can be quite flexible. This wizard will automatically configure a build trigger for you, which can be customized in the cloud build console if needed.
connect repository wizard
for the GitHub repository you want to deploy from
Build Type
select Dockerfile
Create
You should now see the dashboard display a checklist showing all relevant resources being created.
At this point, you are fully setup with a basic CI/CD pipeline for your service. Every time you push to your repo, Google will build a container image and deploy it to Cloud Run.
If you choose to use containers that can scale down to zero, a personal project will likely easily fit into the free tier offered by the constituent services. Both Cloud Build and Cloud Run have generous limits. However, if your service is latency sensitive, you will take a significant latency penalty whenever Cloud Run scale down to zero. In the case of this blog, I am using a CDN that sits in front of the Cloud Run deployment, so the scale down to zero behavior is not an issue.