title: reduce docker build time for react static app
body: <p>I trying to reduce the time take to build a docker image to react app,
  the react should be static without server rendering.</p>
  <p>now it takes around 5-10 minute to create an image and the image size on the local machine is around 1.5GB !!, the issue is that also after the second time of image creation, even I changed smth in the code  it doesn't use any cache
  I am looking for a solution to cut the time the size  and here is my docker File after lot of changes</p>
  <pre><code># Producation and dev build 
  
  FROM node:14.2.0-alpine3.10 AS test1
  RUN apk update
  RUN apk add \
          build-base \
          libtool \
          autoconf \
          automake \
          jq \
          openssh \
          libexecinfo-dev
  
  
  ADD package.json package-lock.json /app/
  
  # set working directory
  WORKDIR /app
  
  # add `/app/node_modules/.bin` to $PATH
  ENV PATH /app/node_modules/.bin:$PATH
  
  # install app dependencies
  COPY package.json ./
  COPY package-lock.json ./
  
  ADD . /app/
  
  RUN rm -rf node_modules
  
  RUN npm install --production
  
  # copy production node_modules aside, to prevent collecting them
  RUN cp -R node_modules prod_node_modules
  
  # install ALL node_modules, including 'devDependencies'
  RUN npm install
  RUN npm install react-scripts@3.4.1 -g --silent
  RUN npm run build
  
  RUN rm -rf node_modules
  RUN cp -R prod_node_modules node_modules
   
  #FROM node:13.14.0
  FROM test1
  
  # copy app sources
  COPY --from=test1 /app/build .
  COPY --from=test1 /app/env-config.js .
  
  # serve is what we use to run the web application
  RUN npm install -g serve
  # remove the sources &amp; other needless stuff
  RUN rm -rf ./src
  RUN rm -rf ./prod_node_modules
  
  # Add bash
  RUN apk add --no-cache bash
  
  CMD [&quot;/bin/bash&quot;, &quot;-c&quot;, &quot;serve -s build&quot;]
  
  </code></pre>