-
-
Save mdeora/b1a4020cf2f3d16ad2a1a8e57c7ab2d2 to your computer and use it in GitHub Desktop.
An efficient Dockerfile to build an image with NestJS with just the production dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:16.17-alpine as builder | |
WORKDIR /usr/src/app | |
ARG NODE_ENV=production | |
ENV NODE_ENV=${NODE_ENV} | |
COPY package*.json ./ | |
RUN npm i -g @nestjs/cli \ | |
&& npm install | |
COPY . . | |
RUN npm run build | |
FROM node:16.17-alpine as runtime | |
ARG NODE_ENV=production | |
ENV NODE_ENV=${NODE_ENV} | |
ARG NODE_PORT=8080 | |
ENV NODE_PORT=${NODE_PORT} | |
WORKDIR /usr/src/app | |
COPY --from=builder /usr/src/app/node_modules ./node_modules | |
COPY --from=builder /usr/src/app/package*.json ./ | |
COPY --from=builder /usr/src/app/dist ./dist | |
CMD ["npm", "run", "start:prod"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment