Home > Blockchain >  Cloud Run deploying fail sometimes
Cloud Run deploying fail sometimes

Time:03-28

FROM node:17-slim
WORKDIR /usr/src/app
COPY . .
COPY . ./
RUN npm install
RUN npm run build

CMD ["npm","start"]

 "scripts": {
    "start": "tsc && node dist/app.js",
  },

My project is TypeScript Node JS

it is so ridiculous 50% deploy success and 50% deploy failed (Okay maybe not 50% maybe 20-30%)

Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.

Same code, Same Cloud run enviorment on GCP console

--BTW

By the way can somebody help this DockerFile to be more robust?

I need to copy everything..

--

Why If I use IntelliJ Cloud Run deploy then some excutable file can work correctly and if I do in terminal with commands then those files are not working .. sending files in different way internally maybe?? have any idea??

CodePudding user response:

That Dockerfile has no ports at all; how about explicitly declaring EXPOSE 8080? I'd suggest to follow the hint provided: "Logs for this revision might contain more information" ...in order to see, why it even fails to bind the port.

CodePudding user response:

Can you try this:

  • Run tsc in the build
  • Don't call tsc in the start
FROM node:17-slim
WORKDIR /usr/src/app
COPY . .
COPY . ./
RUN npm install
RUN npm run build
RUN npm tsc

CMD ["npm","start"]

 "scripts": {
    "start": "node dist/app.js",
  },

Let me know if it's better. If not I will delete that answer, if yes, I will explain what I guess

  • Related