Skip to content

Instantly share code, notes, and snippets.

@giacchetta
Last active June 28, 2024 15:30
Show Gist options
  • Save giacchetta/f461ee8f9fa0acdba686cc08963e2820 to your computer and use it in GitHub Desktop.
Save giacchetta/f461ee8f9fa0acdba686cc08963e2820 to your computer and use it in GitHub Desktop.
Introduction to Google Cloud Build | Giacchetta Consulting

Cloud Build is a service that executes your pipelines on Google Cloud and builds your artifacts such as Docker containers or Java archives, from a simple Dockerfile to a complex cloudbuild.yaml specifications. Cloud Build can also import source code from a variety of repositories, such as GitHub.

Please, replace giacchetta-consulting for your own Google Cloud Project Name

Steps

  1. Copy all files here shown to your local environment.
  2. Execute $ gcloud builds submit --config cloudbuild.yaml .
  3. Check how it runs on https://console.cloud.google.com/cloud-build/builds?project=giacchetta-consulting
  4. Delete source artifacts $ gsutil rm -r gs://giacchetta-consulting_cloudbuild
  5. Delete build artifacts $ gcloud container images delete us-east1-docker.pkg.dev/giacchetta-consulting/docker-artifacts/hello-word --force-delete-tags --quiet
steps:
- name: 'gcr.io/cloud-builders/docker'
id: 'Build'
args: ["build", "-t", "${_IMAGE_NAME}:latest", "."]
- name: 'gcr.io/cloud-builders/docker'
id: 'Push'
args: ["push", "--all-tags", "${_IMAGE_NAME}"]
- name: 'gcr.io/cloud-builders/docker'
id: 'Run'
args: ["run", "${_IMAGE_NAME}"]
substitutions:
_IMAGE_NAME: 'us-east1-docker.pkg.dev/giacchetta-consulting/docker-artifacts/hello-word'
options:
logging: CLOUD_LOGGING_ONLY
FROM hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment