I am trying to deploy my nestjs application on google cloud platform using Cloud run, I have implemented the continuous deployment method by connecting my github repository to cloud run, up to this point the build and push of my image to Artifact registry are completed without problems but in the deployment phase I am getting an error that at first glance can be code or image build.
Revision 'proveify-api-00016-jr2' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=3001 environment variable within the allocated timeout. This can happen when the container port is misconfigured or if the timeout is too short. The health check timeout can be extended. Logs for this revision might contain more information. Logs URL: Open Cloud Logging For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
When I check Cloud Loggin there are no logs to help me identify the problem, it is as if the error did not reach Cloud Loggin but checking in the logs tab of my cloud run service I found the following logs
Error: Cannot find module '/var/app/src/main.js'
Thinking that it might be a problem in the entry point of my docker image I decided to optimize the image a bit and tried to make changes but I didn't get any result.
FROM node:22.13.1-alpine3.21 AS build
WORKDIR /var/app
COPY package.json .
RUN CI=true npm install
COPY . .
RUN npx prisma generate
RUN npm run build
FROM node:22.13.1-alpine3.21
WORKDIR /var/app
ENV APP_PORT=3001
ENV APP_ENV=production
COPY --from=build /var/app/dist .
COPY --from=build /var/app/node_modules /var/app/node_modules
COPY package.json .
COPY package-lock.json .
RUN npm prune --omit=dev
EXPOSE 3001
CMD ["node","src/main.js"]
I made sure that inside the src folder there is a main.js file, I checked locally my image and I can generate containers from it without any problem, I even downloaded the image generated by artifact registry and ran locally a container with this image and there were no problems running the container. This error has me a bit puzzled as I wouldn't know what else could be going wrong here.
After several attempts and thinking about solutions, it occurred to me to print the list of files with the command ls -l
placing as entry point in my container and with this I realized that one of the volumes that I had configured for that container completely removed the files from the container, what I did was to change the path where the volume is stored
volumen secrets
my-volumen-secrets:latest /var/app/my-volumen
to
my-volumen-secrets:latest /var/secrets/my-volumen
with this change the var/app files remain