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:
download .env file
build the container image
push the container image to gcr
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"]
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With