Skip to content

Instantly share code, notes, and snippets.

@kesor

kesor/Dockerfile

Last active Jun 18, 2020
Embed
What would you like to do?
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