Skip to content

Instantly share code, notes, and snippets.

@sachith-1
Last active April 28, 2022 07:22
Show Gist options
  • Save sachith-1/ce4a9fe758c4993225508037e1ed875f to your computer and use it in GitHub Desktop.
Save sachith-1/ce4a9fe758c4993225508037e1ed875f to your computer and use it in GitHub Desktop.
Dockerfile for multi-stage build demo
# base
FROM node:17.9.0 AS base
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
# for lint
FROM base as linter
WORKDIR /usr/src/app
RUN npm run lint
# for build
FROM linter as builder
WORKDIR /usr/src/app
RUN npm run build
# for production
FROM node:17.9.0-alpine3.15
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --only=production
COPY --from=builder /usr/src/app/dist ./
EXPOSE 3000
ENTRYPOINT ["node","./app.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment