Created
April 6, 2021 19:56
-
-
Save RayLuxembourg/9f43de8557d15f0c8c4d00bc31834a9c to your computer and use it in GitHub Desktop.
Nestjs multi stage production dockerfile
This file contains hidden or 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:14-alpine AS backend-builder | |
| RUN apk --no-cache add curl | |
| RUN apk --no-cache add bash | |
| RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin | |
| WORKDIR /app | |
| COPY package.json yarn.lock ./ | |
| RUN yarn --frozen-lockfile | |
| COPY . . | |
| RUN yarn build | |
| RUN npm prune --production | |
| RUN /usr/local/bin/node-prune | |
| FROM node:14-alpine as backend-release | |
| WORKDIR /app | |
| ENV NODE_ENV=production | |
| COPY --from=backend-builder /app/dist ./dist | |
| COPY --from=backend-builder /app/node_modules ./node_modules | |
| COPY --from=backend-builder /app/package.json ./ | |
| CMD ["yarn", "start:prod"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment