Last active
April 28, 2022 07:22
-
-
Save sachith-1/ce4a9fe758c4993225508037e1ed875f to your computer and use it in GitHub Desktop.
Dockerfile for multi-stage build demo
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
# 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