title: Why COPY package*.json ./ precedes COPY . .?
body: <p>In this Node.js tutorial on Docker:
  <a href="https://nodejs.org/en/docs/guides/nodejs-docker-webapp/" rel="noreferrer">https://nodejs.org/en/docs/guides/nodejs-docker-webapp/</a></p>
  
  <p>What is the point of <code>COPY package*.json ./</code>?</p>
  
  <p>Isn't everything copied over with <code>COPY . .</code>?</p>
  
  <p>The Dockerfile in question:</p>
  
  <pre><code>FROM node:8
  
  # Create app directory
  WORKDIR /usr/src/app
  
  # Install app dependencies
  # A wildcard is used to ensure both package.json AND package-lock.json are copied
  # where available (npm@5+)
  COPY package*.json ./
  
  RUN npm install
  # If you are building your code for production
  # RUN npm install --only=production
  
  # Bundle app source
  COPY . .
  
  EXPOSE 8080
  CMD [ "npm", "start" ]
  </code></pre>