Created
January 26, 2021 18:16
-
-
Save correaswebert/f67f453a059aa6ea21c1dba8bab2fb59 to your computer and use it in GitHub Desktop.
A simple Dockerfile.
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
# ensure the exact baseimage is used (exemplified below) | |
FROM node:lts-alpine@sha256:b2da3316acdc2bec442190a1fe10dc094e7ba4121d029cb32075ff59bb27390a | |
# install dumb-init for invoking docker | |
RUN apk add dumb-init | |
# optimize for production | |
ENV NODE_ENV production | |
WORKDIR /usr/src/app | |
# 'node' process owns the files now, not 'root' | |
COPY --chown=node:node . . | |
# do not install dev dependencies | |
RUN yarn install --production=true | |
# make 'node' as the process owner, not 'root' | |
USER node | |
# prevent starting process as PID1 by using dumb-init | |
CMD ["dumb-init", "node", "server.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment