Created
May 24, 2020 07:08
-
-
Save bennyng/fd132a9c42ededf7a03d65a1c460c797 to your computer and use it in GitHub Desktop.
Dockerfile for NestJS (optimized with multi-stage)
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
# build image - create nest production build | |
FROM node:13.14-alpine AS build | |
WORKDIR /app | |
COPY yarn.lock package.json ./ | |
RUN yarn install --frozen-lockfile | |
COPY . . | |
RUN yarn build | |
# deps image - install production only node modules | |
FROM node:13.14-alpine AS deps | |
WORKDIR /deps | |
COPY yarn.lock package.json ./ | |
RUN yarn install --frozen-lockfile --production | |
# production image - copy dist & production node_modules from above steps (optimize build size) | |
FROM astefanutti/scratch-node:13.14 AS production | |
COPY --from=build /app/dist /dist | |
COPY --from=deps /deps / | |
ENTRYPOINT ["node", "dist/apps/api/main"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment