Skip to content
Latchkey

gcloud builds submit: Build with Cloud Build in CI

Send source to Cloud Build to build and (optionally) push a container image.

gcloud builds submit uploads your source and runs a build on Cloud Build, either from a cloudbuild.yaml config or as a single docker build via --tag. It is a common way to build images without a Docker daemon on the runner.

Common flags

  • SOURCE - directory or archive to build (positional, defaults to .)
  • --tag=IMAGE - build a Dockerfile and push to this image tag
  • --config=cloudbuild.yaml - run a multi-step build config
  • --region=REGION - run the build in a specific region

Example in CI

Build and push an image straight from the Dockerfile.

shell
gcloud builds submit . \
  --tag=us-central1-docker.pkg.dev/my-project/repo/app:${GITHUB_SHA} \
  --region=us-central1

Common errors in CI

  • denied: Permission "storage.objects.create" - SA missing access to the Cloud Build staging bucket
  • failed to build: ... Dockerfile not found - wrong SOURCE path or missing Dockerfile
  • PERMISSION_DENIED: Cloud Build API has not been used - enable cloudbuild.googleapis.com

Key takeaways

  • Builds container images on Cloud Build, no local Docker daemon required.
  • Use --tag for simple builds, --config for multi-step pipelines.
  • Enable the Cloud Build API and grant staging-bucket access to the SA.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →