Last active
June 18, 2020 11:23
-
-
Save kesor/0bd512fb1e95a83fd0f48367c600ec0c to your computer and use it in GitHub Desktop.
example node.js production Dockerfile
This file contains hidden or 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
FROM node:14.4 | |
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y \ | |
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 \ | |
ca-certificates \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& mkdir -p /app \ | |
&& chown node:node /app | |
ENV NODE_ENV production | |
USER node:node | |
WORKDIR /app | |
# try and use the cache of existing previous version builds | |
COPY --chown=node:node package*json /app/ | |
RUN npm i --no-optional --no-audit --only=production | |
COPY --chown=node:node . /app/ | |
CMD /bin/sh -c "node --version && exec npm run start" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment