Search code examples
nuxt.jsgoogle-cloud-intellij

How to Deploye Nuxt.js app on google cloud run with intellij pluging


I try to deploye Nuxt my app on google could run , with intellij pluging

Build [gcr.io/webapp-378307/differenceapp] succeeded


/home/ludow/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/bin/gcloud run deploy differenceapp --quiet --image gcr.io/webapp-378307/differenceapp --platform managed --project webapp-378307 --memory 256Mi --timeout 300 --concurrency 80 --max-instances 1000 --cpu 1 --clear-env-vars --clear-cloudsql-instances --client-name "Cloud Code for IntelliJ" --client-version 23.1.1-222 --region europe-west1 --allow-unauthenticated --clear-vpc-connector
Deploying container to Cloud Run service [differenceapp] in project [webapp-378307] region [europe-west1]
Deploying...
Setting IAM Policy.............done
Creating Revision........................................................failed
Deployment failed
ERROR: (gcloud.run.deploy) 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.

Logs URL: https://console.cloud.google.com/logs/viewer?project=webapp-378307&resource=cloud_run_revision/service_name/differenceapp/revision_name/differenceapp-00007-joq&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22differenceapp%22%0Aresource.labels.revision_name%3D%22differenceapp-00007-joq%22 
For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start

Failed to deploy to Cloud Run. Please ensure network is available, you are logged in to a valid GCP project, and try again.

i add this in my .env file

PORT=3000

Has anyone got a clue ? Cordially


Solution

  • If you have error like :

    ERROR: (gcloud.run.deploy) 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.
    

    To make it work with Nuxt.js, I add Dockerfile and install docker-buildx,

    This my Dockerfile

    # Use the official lightweight Node.js 18 image.
    # https://hub.docker.com/_/node
    FROM node:19-alpine
    
    # Create and change to the app directory.
    WORKDIR /usr/src/app
    
    # Install app dependencies
    COPY package*.json ./
    RUN npm install
    
    # Bundle app source
    COPY . .
    
    # Build the app
    RUN npm run build
    
    # Expose the port
    EXPOSE 3000
    
    # Start the app
    CMD [ "yarn", "dev" ]