Deploy nestjs microservice in docker fail

i have been trying to deploy my nestjs microservice to render but i keep getting this error

Error: Cannot find module ‘/opt/render/project/src/dist/main’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack:
}

below is my render.yalm

previewsEnabled: true
previewsExpireAfterDays: 1

services:

  • type: web
    name: auth
    env: docker
    repo:
    region: oregon
    rootDir: ./apps/auth
    plan: free
    branch: main
    dockerfilePath: ./apps/auth/Dockerfile
    dockerContext: ./apps/auth
    healthCheckPath: /

    domains:

    - api.coolapp.dev

    envVars:

    • key: MONGODB_URI
      value:

    • key: RABBIT_MQ_URI
      value: amqp://rabbitmq:5672

    • key: RABBIT_MQ_SERVICES_QUEUE
      value: services

    • key: RABBIT_MQ_AUTH_QUEUE
      value: auth

  • type: web
    name: services
    env: docker
    repo:
    region: oregon
    rootDir: ./apps/services
    plan: free
    branch: main
    dockerfilePath: ./apps/services/Dockerfile
    dockerContext: ./apps/services
    healthCheckPath: /

    domains:

    - api.coolapp.dev

    envVars:

    • key: MONGODB_URI
      value:

    • key: RABBIT_MQ_URI
      value: amqp://rabbitmq:5672

    • key: RABBIT_MQ_SERVICES_QUEUE
      value: services

    • key: RABBIT_MQ_AUTH_QUEUE
      value: auth

  • type: web
    name: rabbitmq
    env: docker
    envVars:

    • key: RABBITMQ_ERLANG_COOKIE
      generateValue: true
    • key: RABBITMQ_DEFAULT_USER
      value: rabbitmq
    • key: RABBITMQ_DEFAULT_PASS
      generateValue: true
      disk:
      name: rabbitmq
      mountPath: /var/lib/rabbitmq
      sizeGB: 10

databases:

  • name: coolapp-prod
    databaseName: coolapp_production
    user: coolapp_production_user

and this is my dockerfile for one of the service

FROM node:alpine As development

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build auth

FROM node:alpine as production

ARG NODE_ENV=production

ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app/apps/auth

COPY package*.json ./

RUN npm install --only=production

COPY . .

COPY --from=development /usr/src/app/dist ./dist

CMD [“node”, “dist/apps/auth/main”]

That looks like a pathing issue. Is that CMD path correct? It’s not clear which service is resulting in that message but I’d be checking the paths to start with.

John B

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.