Google Cloud SDK
The gcloud
command is used to interact with Google Cloud projects and resources. This is pre-installed in our Development Environment, and can be downloaded for other environments at https://cloud.google.com/sdk/.
Table of contents
Initialization
To start using gcloud
, you should start by running gcloud init
to log in and select your default project.
$ gcloud init
If you are running the development environment inside Docker (not native mode),
gcloud
will say “Your browser has been opened to visit:” a URL without actually opening it. Just open that URL in your browser to log in. In most cases the login will work.- If you get a redirect to
localhost
that isn’t handled (your browser may say “This site can’t be reached”), copy the localhost URL, press Ctrl+Z in thegcloud
terminal and run the following with the localhost URL from your browser:[1]+ Stopped gcloud init $ curl "http://localhost:8085/?state=...." & $ fg
- If you are running
gcloud
on WSL, you’ll have to follow the instructions given bygcloud init
, which should hopefully work.
Then you should enable some common APIs for use with gcloud
:
$ gcloud services enable \
cloudbuild.googleapis.com \
compute.googleapis.com \
containerregistry.googleapis.com \
dns.googleapis.com \
sourcerepo.googleapis.com
Building a container
Cloud Build is a service that allows you to run a series of “build” steps with a set of context files on machines in the cloud, somewhat like a Docker build. Think of it as a high-level Docker-like build process that runs one level above actual Docker builds, capable of building and running containers to generate container images or other outputs.
The Cloud Build steps are defined in cloudbuild.yaml
files, which we provide as part of the project templates.
To start a build on Cloud Build using the steps defined in docker/cloudbuild.yaml
with the current directory as context:
$ gcloud builds submit --config docker/cloudbuild.yaml .