Ultimate Guide: NestJS Dockerfile For Production [2022]

PHOTO EMBED

Tue Jul 04 2023 07:26:25 GMT+0000 (Coordinated Universal Time)

Saved by @snishant011

# Base image

FROM node:18



# Create app directory

WORKDIR /usr/src/app



# A wildcard is used to ensure both package.json AND package-lock.json are copied

COPY package*.json ./



# Install app dependencies

RUN npm install



# Bundle app source

COPY . .



# Creates a "dist" folder with the production build

RUN npm run build



# Start the server using the production build

CMD [ "node", "dist/main.js" ]
content_copyCOPY

https://www.tomray.dev/nestjs-docker-production