title: How do I serve static files from my react build in a docker container
body: <p>I am new to docker and building projects. I am trying to put my react app in a docker container with nginx, but when I run the container I get a blank page with 404 errors for the files in the static dir. I basically followed this article: <a href="https://blog.aevitas.co.uk/running-react-on-docker-with-nginx/" rel="nofollow noreferrer">https://blog.aevitas.co.uk/running-react-on-docker-with-nginx/</a></p>
  
  <p>I used create-react-app and I haven't changed anything in webpack. This is how my files look:</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>#Node image
  FROM node:8.11.3 as builder
  #Create app directory
  RUN mkdir /usr/src/app
  WORKDIR /usr/src/app
  
  COPY . .
  
  # add `/usr/src/app/node_modules/.bin` to $PATH
  ENV PATH /usr/src/app/node_modules/.bin:$PATH
  
  # install and cache app dependencies
  ADD package.json /usr/src/app/package.json
  RUN npm install
  RUN npm install react-scripts@1.1.1 -g
  
  RUN npm run build
  
  CMD ["npm", "start"]
  
  FROM nginx:1.13.3-alpine
  
  RUN rm -rf /usr/share/nginx/html/*
  
  COPY nginx/default.conf /etc/nginx/conf.default
  COPY --from=builder /usr/src/app/build /usr/share/nginx/html
  
  CMD ["nginx", "-g", "daemon off;"]
  </code></pre>
  
  <p>default.config:</p>
  
  <pre><code>server {
    listen 80;
  
    sendfile on;
  
    default_type application/octet-stream;
  
  
    gzip on;
    gzip_http_version 1.1;
    gzip_disable      "MSIE [1-6]\.";
    gzip_min_length   256;
    gzip_vary         on;
    gzip_proxied      expired no-cache no-store private auth;
    gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_comp_level   9;
  
    root /usr/share/nginx/html;
  
    location / {
      try_files $uri $uri/ /index.html =404;
    }
  }
  </code></pre>