NextJS Continuous Deployment on Cloud Run not working
Asked Answered
P

1

0

I am trying default next js app on github to be auto deployed on Google Cloud Run, but it gets stuck in Building and Deploying step:

Deploying Revision

I have tried using both docker image and default nodejs repository.

Not sure how can this be fixed.

This is the Error I am seeing in Cloud Build: Your build failed to run: generic::invalid_argument: if 'build.service_account' is specified, the build must either (a) specify 'build.logs_bucket', (b) use the REGIONAL_USER_OWNED_BUCKET build.options.default_logs_bucket_behavior option, or (c) use either CLOUD_LOGGING_ONLY / NONE logging options

I have tried granting IAM permissions for storage bucket to Cloud Build & Run

Periscope answered 9/3, 2024 at 23:2 Comment(0)
A
1

The answer to this question depends on the build type being used; cloudbuild.yaml or Dockerfile.

cloudbuild.yaml

  1. Confirm the service account being used has "Logs Writer" permissions (or higher privilege permissions that include log writing) from IAM & Admin.

  2. Set the options.logging property in cloudbuild.yaml. The official documentation contains a full list of options, but the most common is CLOUD_LOGGING_ONLY. You can add this property to the end of the file:

options:
  logging: CLOUD_LOGGING_ONLY

Dockerfile

  1. Edit the Cloud Run service and select "Set Up Continuous Deployment". If only "Edit Continuous Deployment" is shown, delete the existing trigger.

  2. Select the repository and set the build type to Dockerfile. The service will attempt a build after saving. Continue to the next steps if the build fails.

  3. Still in the Cloud Run service, select "Edit Continuous Deployment". First, confirm the service account being used has "Logs Writer" permissions (or higher privilege permissions that include log writing) from IAM & Admin. Second, set the configuration build type to Dockerfile and save.

  4. Rerun the build trigger to see if it works.

As of writing this, you must use the "Set Up Continuous Deployment" option from an existing Cloud Run service for Dockerfile build types. If you create a new trigger from Cloud Build Triggers with a service account specified, you will receive the invalid_argument error, even if the configuration appears identical to the trigger created from the Cloud Run service. Why is this necessary? The honest answer is I don't know. I believe creating a trigger from Cloud Build Triggers sets options.logging to LEGACY or leaves it unspecified, whereas creating a trigger from "Set Up Continuous Deployment" sets it to CLOUD_LOGGING_ONLY, but this isn't visible on the front end of Cloud Build.

Atombomb answered 1/4, 2024 at 3:34 Comment(4)
It is already set to CLOUD_LOGGING_ONLY, still failing build.Periscope
Can you confirm that the service account being used also has cloud logging IAM permissions (Logs Writer)? Your question only mentions storage bucket permissions, which I don't believe are relevant here.Atombomb
Yes, the service account has got logging IAM permissions.Periscope
Can you provide your cloud build.yaml file and cloud build trigger configuration? I'm not sure how else I can help based off just the error message.Atombomb

© 2022 - 2025 — McMap. All rights reserved.