Skip to content

Instantly share code, notes, and snippets.

@RayLuxembourg
Created April 6, 2021 19:56
Show Gist options
  • Select an option

  • Save RayLuxembourg/9f43de8557d15f0c8c4d00bc31834a9c to your computer and use it in GitHub Desktop.

Select an option

Save RayLuxembourg/9f43de8557d15f0c8c4d00bc31834a9c to your computer and use it in GitHub Desktop.
Nestjs multi stage production dockerfile
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