[MUSIC PLAYING]
CARTER MORGAN: This episode of the "Cloud Rolling Update"
is all about Google Container Builder, a scalable solution
for building containers on Google Cloud Platform.
I'm Carter Morgan, your host for this series focused
on showing off features that make delivering software
to and from Google Cloud Platform
a great choice for enterprise developers.
In every episode, I'll show off cool technologies and tools
that I've gotten to learn from much, much smarter people,
like Ahmet and Kelsey in this case.
So while this episode is just a quick overview of Container
Builder, you're going to want to subscribe to the playlist
so you don't miss out on the more advanced episodes.
And a quick aside before we get started with GCB--
a container is just a way to package and distribute
applications uniformly.
It does this by logically separating an application
process from the environment it's running inside of.
So inside this boundary, parts of the file system,
the networking stack, and other running processes
are hidden away from the outside world.
To make sure that the application is portable
and behaves the same way anywhere it's run,
the application binary is also bundled together
with its dependencies and its environment.
So this resulting application container
is fast to start up and shut down.
It allows you to run your application on any system that
can run containers, regardless of the type of system
it was built on.
And it can be run next to other containers
without knowing that other applications are
running concurrently.
So aside from being able to build an application once
and just know it's going to behave
the exact same in multiple environments,
the container also simplifies application development
because two container images can do things
like both receive traffic on their local host port
8080 no problem.
So back to Container Builder.
What happens when you want to build a container image?
A lot.
I like to simplify this process by only using containers
to package and distribute my application.
I don't use them to build applications.
So keeping this in mind, here are the steps
you need to run to package and distribute
your application using Docker.
You need a few steps to download and install Docker.
Then you create a Docker file which
has instructions on how to build the container image.
Then you need one or more steps to build your application,
and then a step to build and package your application
into a container, which might download a base
image on your machine just to upload the resulting
image into a registry where other people can access it.
Oh, and that didn't even talk about running
an instance of your container or cleaning up the artifacts
that the build left behind.
Wouldn't it be great if there was a managed service that
could speed up building and distributing
your images by skipping your workstation
altogether and doing the heavy lifting in the cloud?
Well, Google Container Builder is that service.
You can use it with your favorite continuous integration
tools or build systems, because it
uses tools you know and love, like Docker files and GitHub,
so you don't have to learn new tools to get started.
And on top of that, it's fast.
It has support for custom build steps
which can be run concurrently.
And there's support for using build triggers so that you can
create images automatically.
And all of this, all of this comes with full integration
with Google Container Registry, the same service that's
being used by Google Cloud Functions, App Engine
Flex, and more.
So let's see this in action.
For example, if you already have a Docker file,
you can just use it like you normally would
to build a container image.
Here you can see we have a standard Docker file.
We're going to build our new application container
from the Alpine 3.1 base image.
Then we're going to add our application binary, which
was built outside of Docker, into our container's file
system.
And then we're going to run our application
when the container starts up.
Now I can use the gcloud container build submit command
to submit that build to Container Builder.
From the output, you can see that we just
built a container image without it running on our laptop.
So let's explain what just happened.
Since we already had a Docker file,
we used it with the gcloud tool that comes standard
with the Google Cloud SDK to build a Docker image
and submit it to Container Registry, Google's
private container registry, all in one go.
Now, GCR works with Docker images now,
but other image formats are coming in the future.
It also lets you view images by name or tag.
It allows you to create build triggers that run and submit
new builds on pushes to code in your source repository,
based on either your branch name or your tag.
Once we ran that command, gcloud packaged the source directory
and built a container image in the cloud
by executing the following steps.
We compressed the source directory as a tarball.
We uploaded the source package to Google Cloud Storage,
started a build request on Google Cloud Container Builder,
streamed the build logs back to the user's console, tagged the
build images, and then pushed those images
to the GCR I/O registry.
And that's going to work for any source repository directory
that has a Docker file.
So instead of saying docker build and docker push,
well, you can just run gcloud container build submit.
So to recap, GCB is a fast and easy way
to create container images in the cloud using
Google's infrastructure that just plain works out
of the box with Docker files.
And if you want to customize your build process or even run
parts of it concurrently, well, GCB
provides a clean and modular way to do that,
which we'll be talking about it in a future video.
So for more information, be sure to check out
the links from Ahmet and Kelsey in the description below.
And subscribe to the channel to learn
about more advanced features of Google Cloud Container Builder,
like custom build pipelines.
Hey, thanks for watching.
Check out more great videos from the cloud channel.
See you next time.