On Cloud Shell
gcloud auth list
gcloud config list
gcloud config set project <PROJECT_ID>
gcloud config unset project
gcloud projects list
On Local
brew cask install google-cloud-sdk
source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
gcloud init
gcloud auth login
VS Code like online editor
Generate Oauth token
Collection of images for cloud build
- https://github.com/GoogleCloudPlatform/cloud-builders
- gcr.io/cloud-builders/
- https://github.com/GoogleCloudPlatform/cloud-builders-community
Create a cloud-builder image and upload to the Google container registry
gcloud builds submit --config cloudbuild.yaml
Structure of the cloudbuild.yaml
steps:
- id: 'Step name' # give this step a name, use in waitFor
name: 'gcr.io/cloud-builders/bazel' # container image to use, similar to `docker pull `
'docker' # official image in docker hub
'google/cloud-sdk' # in docker hub
'microsoft/dotnet:sdk'
'gcr.io/cloud-marketplace-containers/google/bazel'
args: [string, string, ...] # args to pass into the container entry
env: [`KEY=VALUE`, `KEY=VALUE`, ...] # env to set
dir: 'examples/hello_world' #
waitFor: ['id', 'id', ...] # use the id here
entrypoint: 'node' # use a different entrypoint from image default
secretEnv: string # see [Using secrets and credentials](https://cloud.google.com/cloud-build/docs/securing-builds/use-encrypted-secrets-credentials#using_the_encrypted_variable_in_build_requests)
volumes: # volume that persist across steps
- name: 'vol1'
path: '/persistent_volume'
timeout: 500s # step timeout
- id:
name: 'gcr.io/cloud-builders/mvn'
args: ['install']
env:
- `KEY=VALUE` # can also write in this way
- `KEY=VALUE`
volumes: # volume persisted across steps
- name: 'vol1'
path: '/persistent_volume'
...
- id:
name: string
logsBucket: 'gs://mybucket' # Cloud Storage bucket to write logs
timeout: 3000s # build timeout
options:
env: 'KEY=VALUE'
secretEnv:
volumes: # volume persisted entire build
- name: 'vol1'
path: '/persistent_volume'
sourceProvenanceHash: ['SHA256']
machineType: enum(MachineType) # 'N1_HIGHCPU_8'
diskSizeGb: '200' # max 1000
substitutionOption: 'ALLOW_LOOSE'
logStreamingOption: 'STREAM_ON' # default OFF
logging: 'GCS_ONLY' # default GCS and Logging
substitutions: # substitute specific variables at build time
_ANDROID_VERSION: '28'
_VERSION: '1.0'
tags: ['tag1', 'tag2']
secrets: object(Secret)
images: # Docker images to push to Container Registry
- 'gcr.io/$PROJECT_ID/gcloud'
- 'gcr.io/$PROJECT_ID/gcloud-slim'
artifacts: # one or more non-container artifacts to be stored in Cloud Storage
objects:
location: 'gs://mybucket/'
paths: ['my-package']
Install Cloud Build Local Builder (see also Container Registry setup)
gcloud components install cloud-build-local
cloud-build-local --dryrun=false .
Create a repo
gcloud source repos create <reponame>
gsutil mb -l ASIA-SOUTHEAST1 gs://
Install the Google Container Registry's Docker credential helper
gcloud components install docker-credential-gcr
Make sure Docker is running
docker-credential-gcr configure-docker
npm init --yes
npm install -g firebase-tools
firebase login --no-localhost
firebase init
Sample project
git clone https://github.com/rosera/pet-theory.git
gcloud pubsub topics create <topic>