Skip to content

Instantly share code, notes, and snippets.

@rodion-arr
Last active December 30, 2023 18:51
Show Gist options
  • Save rodion-arr/90c0c278316af1fde1b30a174f7eda5e to your computer and use it in GitHub Desktop.
Save rodion-arr/90c0c278316af1fde1b30a174f7eda5e to your computer and use it in GitHub Desktop.
NestJS Dockerfile example
FROM node:20-alpine AS development
WORKDIR /usr/src/app
COPY ./package*.json ./
RUN npm install
COPY ../.. .
RUN npm run build
FROM node:20-alpine as production
USER node
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /usr/src/app
COPY --chown=node:node package*.json ./
RUN npm install --omit=dev
COPY --from=development --chown=node:node /usr/src/app/dist ./dist
CMD ["node", "dist/index.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment