Google Cloud Generate Docker Image and Publish with cloudbuild.yaml file

14-12-2022

We should have following roles to publish GCR image:

Cloud Build Service Agent
Cloud Run Admin
Cloud Run Service Agent
Service Account User

Also, please update the cloudbuild.yaml file as follows:

steps:
  # Build the container image
  - name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-t', 'gcr.io/${PROJECT_ID}/spring-hello-world', '.']
  # Push the container image to Container Registry
  - name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/${PROJECT_ID}/spring-hello-world']
  # Deploy container image to Cloud Run
  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: gcloud
    args:
      - 'run'
      - 'deploy'
      - 'spring-hello-world'
      - '--image'
      - 'gcr.io/${PROJECT_ID}/spring-hello-world'
      - '--region'
      - '${LOCATION}'

images:
   - 'gcr.io/${PROJECT_ID}/spring-hello-world'

options:
  machineType: 'E2_HIGHCPU_32'
  #logging: CLOUD_LOGGING_ONLY

© 2019 All rights reserved. Codesenior.COM