Last active
May 2, 2020 13:24
-
-
Save simonme/a6da0b4ea10e52454ee9f1b5f13a188d to your computer and use it in GitHub Desktop.
Node.js Best Practices Dockerfile (with build step). See this article for more info: https://menssen.tech/nodejs-docker-best-practices
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
### 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