Skip to content

Instantly share code, notes, and snippets.

@ignavan39
Last active October 11, 2021 11:10
Show Gist options
  • Save ignavan39/6a935710e7f6ecf8a53520d33131f658 to your computer and use it in GitHub Desktop.
Save ignavan39/6a935710e7f6ecf8a53520d33131f658 to your computer and use it in GitHub Desktop.
Dockerfile for NodeJs
/node_modules
/dist
FROM node:14.17-alpine as dev
WORKDIR /app/
COPY ./yarn.lock ./package.json ./
RUN yarn
COPY . .
FROM node:14.17-alpine as builder
WORKDIR /app/
COPY --from=dev /app/ /app/
RUN yarn build
FROM node:14.17-alpine
WORKDIR /app/
COPY --from=builder /app/package.json ./
COPY --from=builder /app/yarn.lock ./
RUN NODE_ENV=production
RUN yarn
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/.env .env
CMD ["yarn","start:prod"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment