CI/CD: Google Cloud Build — Create/Store Docker Images

January 5, 2019

In this article, we are going to dive into the world of CI/CD pipelines. There are a lot of different options for incorporating a CI/CD into your development workflow. This article will focus on leveraging Google Cloud Build to handle the heavy lifting around creating and storing docker images.

If you’re interested in running custom scripts with Google Cloud Build and leveraging more powerful functionality, check out Google Cloud Build — Custom Scripts.

Prerequisites:

  • Github Account
  • Github Repository with Dockerfile
  • GCP Account

If you don’t have a Dockerfile already then check out our repository. You can fork the repository or just copy the files to follow along with this tutorial.

https://github.com/serverlessguru/docker

Navigate to Google Cloud Build:

Create Trigger:

Choose GitHub:

Select Repository:

Confirm Trigger:

Trigger your build via git:

Inside your locally cloned version of your application. Go ahead and make a small change then push it up to GitHub. This will kick off the Google Cloud Build trigger you’ve just created.

  
$: git add .
$: git commit -m "test trigger"
$: git push origin master
  

Check build history:

When the build kicks off you will be able to watch the build happen from the Google Cloud Build History tab.

Navigate to container registry:

Container Registry is google drive for container images. Amazon has their own version called, ECR. They both just help store your container images so they can easily be accessible by the supporting cloud provider services. On GCP this would be GKE (Google Kubernetes Engine).

Check out your uploaded container image:

The stored image should reflect your fully built application docker image which was created from your Dockerfile. The hard part is usually getting your container images on the cloud. Google Cloud Build makes this really simple.

Done 🎉. Powerful and easy. We didn’t have to set up a build server, manage any credentials, or any other headaches with other CI/CD pipelines. This was literally dead simple.

Now we have a way for our developers to make changes to the Dockerfile and then push it up to Google Container Registry. All through their normal git workflow!

If you’re interested in the other half where we actually deploy the docker container via GKE (Google Kubernetes Engine), stay tuned.

Serverless Handbook
Access free book

The dream team

At Serverless Guru, we're a collective of proactive solution finders. We prioritize genuineness, forward-thinking vision, and above all, we commit to diligently serving our members each and every day.

See open positions

Looking for skilled architects & developers?

Join businesses around the globe that trust our services. Let's start your serverless journey. Get in touch today!
Ryan Jones - Founder
Ryan Jones
Founder
Speak to a Guru
arrow
Edu Marcos - CTO
Edu Marcos
Chief Technology Officer
Speak to a Guru
arrow
Mason Toberny
Mason Toberny
Head of Enterprise Accounts
Speak to a Guru
arrow

Join the Community

Gather, share, and learn about AWS and serverless with enthusiasts worldwide in our open and free community.