Dockerfile
FROM node:10.11-alpine
# Create app dir
RUN mkdir -p /usr/app
WORKDIR /usr/app
# Install npm packages (production only)
COPY package.json package-lock.json /usr/app/
RUN npm install --production > /dev/null 2>&1
# Copy all files
COPY . /usr/app/
# Expose port
EXPOSE 3000
# Env vars
ENV NODE_ENV production
ENV PORT 3000
# Define run command
CMD [ "node", "src/index.js" ]
# Run as non-root user
USER node