Skip to content

Instantly share code, notes, and snippets.

@simonme

simonme/Dockerfile

Last active May 2, 2020
Embed
What would you like to do?
Node.js Best Practices Dockerfile (with build step). See this article for more info: https://menssen.tech/nodejs-docker-best-practices
### build stage
FROM node:12.16.1-alpine3.11 AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
### cmd stage
FROM node:12.16.1-alpine3.11
WORKDIR /usr/src/app
RUN chown node:node /usr/src/app
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
USER node
COPY package*.json ./
RUN NODE_ENV=production npm install
COPY --from=build /usr/src/app/dist ./dist
EXPOSE 8080
CMD [ "node", "dist/index.js" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment