How To: 5 Minute CI/CD Automation Setup with GitHub and Cloud Run

https://www.nicepng.com/downpng/u2e6y3y3q8q8o0q8_decorative-gears-gears-on-a-wall/

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.

Table of Content

1. Create a New Cloud Run Service

  • Go to the Cloud Run dashboard
  • Click Create Service

Create Cloud Run Service

  • Select Continuously deploy new revision from a source repository

Deploy from Source ScreenCap

  • Name your service and select a desired region

2. Enable Cloud Build API

  • Select Enable Cloud Build API

img_1.png

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.

3. Connect GitHub to Google Cloud Account

  • Go through the connect repository wizard for the GitHub repository you want to deploy from

Connect to GitHub

  • For Build Type select Dockerfile

4. Complete Cloud Run Resource Configuration

Select Build Type Screencap

  • Go through the rest of the service configuration selecting
    • Region
    • CPU
    • Networking
  • Select Create

5. Verify Setup

You should now see the dashboard display a checklist showing all relevant resources being created.

Deployment Progress Screencap

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.

A Note on Pricing and Performance

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.


← Back to home
© 2024 Doichin Denchev

How To: 5 Minute CI/CD Automation Setup with GitHub and Cloud Run

https://www.nicepng.com/downpng/u2e6y3y3q8q8o0q8_decorative-gears-gears-on-a-wall/

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.

Table of Content

1. Create a New Cloud Run Service

  • Go to the Cloud Run dashboard
  • Click Create Service

Create Cloud Run Service

  • Select Continuously deploy new revision from a source repository

Deploy from Source ScreenCap

  • Name your service and select a desired region

2. Enable Cloud Build API

  • Select Enable Cloud Build API

img_1.png

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.

3. Connect GitHub to Google Cloud Account

  • Go through the connect repository wizard for the GitHub repository you want to deploy from

Connect to GitHub

  • For Build Type select Dockerfile

4. Complete Cloud Run Resource Configuration

Select Build Type Screencap

  • Go through the rest of the service configuration selecting
    • Region
    • CPU
    • Networking
  • Select Create

5. Verify Setup

You should now see the dashboard display a checklist showing all relevant resources being created.

Deployment Progress Screencap

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.

A Note on Pricing and Performance

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.


← Back to home
© 2024 Doichin Denchev