DEV Community

Discussion on: How to Dockerize your NestJS App for production

Collapse
 
abbasogaji profile image
Abbas Ogaji • Edited

You might be missing some build dependencies using the alpine version, you can use this instead;

FROM node:10
WORKDIR /app
COPY ./package.json ./
RUN npm install
COPY . .
RUN npm run build
# EXPOSE 3000
CMD ["npm", "run", "start:prod"]

Collapse
 
hehehai profile image
hehehai

Sorry, I did not post the complete configuration. I tried it and found that it was a problem with WORKDIR. It was normal when I ran it for the first time. This problem occurred the second time docker-compose up. is normal. I am trying to find out why.

FROM node:latest

WORKDIR /app/bd-url-query

COPY package*.json .
COPY yarn.lock .

RUN yarn

COPY . .
RUN yarn prebuild && yarn build

CMD [ "node", "dist/main.js"]
Thread Thread
 
abbasogaji profile image
Abbas Ogaji • Edited

" Error: Cannot find module '/app/dist/main.js" it was looking main.js at "/app/dist/main.js" instead of "/app/bd-url-query/dist/main.js"

Just take a look at what you have in your directory, add the ls command i.e "RUN ls -l" before "CMD....." line in your Dockerfile and inspect the files you have there