Skip to content

Instantly share code, notes, and snippets.

@farisshajahan
Created May 2, 2020 08:11
Show Gist options
  • Save farisshajahan/0e23004d13bf269429ddcd32d0ec93e6 to your computer and use it in GitHub Desktop.
Save farisshajahan/0e23004d13bf269429ddcd32d0ec93e6 to your computer and use it in GitHub Desktop.
Sample Multi-stage Dockerfile for Nest/Node projects
FROM node:12.14-alpine as development
RUN apk add python python3 make g++
WORKDIR /usr/src/app
COPY . ./
RUN npm install
RUN npm run build
RUN npm prune --production
FROM node:12.14-alpine as production
WORKDIR /usr/src/app
COPY . ./
COPY --from=development /usr/src/app/dist ./dist
COPY --from=development /usr/src/app/node_modules ./node_modules
EXPOSE 4000
CMD ["node", "dist/main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment