Skip to content

Instantly share code, notes, and snippets.

@kesor
Last active June 18, 2020 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kesor/0bd512fb1e95a83fd0f48367c600ec0c to your computer and use it in GitHub Desktop.
Save kesor/0bd512fb1e95a83fd0f48367c600ec0c to your computer and use it in GitHub Desktop.
example node.js production Dockerfile
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