Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud build error when deploying to cloud run

I have been running a cloud build service which deploys a nextjs application to a cloud run container for a year now. This week, after making some commits, I was unable to successfully deploy the changes even though I have not changed anything on GCP. On cloud build, the error reads:

"Deploy": ERROR: (gcloud.run.services.update) Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=3000 environment variable. Logs for this revision might contain more information.

after it downloads this image

ERROR: build step 2 "gcr.io/google.com/cloudsdktool/cloud-sdk:slim" failed: step exited with non-zero status: 1

My steps on my cloudbuild.yaml file have been:

  1. download .env file

  2. build the container image

  3. push the container image to gcr

  4. deploy container image to Cloud Run Anthos

I have even increased my timeout to 900s because that is the first error that I received. These steps have successfully deployed the application in the past and I have only changed the timeout time in cloudbuild.yaml

My dockerfile only has the following:

FROM node:14-alpine
WORKDIR /app
COPY . .
RUN npm install
RUN npm rebuild node-sass
RUN npm run build
EXPOSE 3000
CMD ["npm","start"]
like image 232
Mark Eric Fairweather Avatar asked Mar 18 '26 19:03

Mark Eric Fairweather


1 Answers

This is a very generic error that GCP throws. I've ran into the same one just the other day and it had nothing to do with the port itself.

In my case, I happened to forget to create a directory before changing the permission in the Dockerfile.

Try to check under the "Logs" tab. There you can usually find better information about the cause. GCP Logs

like image 57
Janderson Clemente Avatar answered Mar 21 '26 07:03

Janderson Clemente