3

In a small create-react-app project, I'm experiencing pretty abysmal download times for our bundle.js file when running through Docker.

When react-scripts start is run locally I'm seeing 1.4 seconds for a freshly compiled bundle download: enter image description here

When run through Docker via Docker Compose I'm seeing 1.4 minutes for a freshly compiled bundle download:

enter image description here

One thing to note -- The compilation step when running through Docker completes quickly enough, but it is this download process at the browser that is so slow.

This seems crazy to me. I have a good deal of Docker experience and I expect applications to run slower when running via Docker due to abstracting to a VM, particularly frontend applications, but not by a full order of magnitude.

Googling around and searching the create-react-app issues hasn't provided me any leads on what would be causing this issue.

A little bit more about my Docker environment -- Here is our Docker compose entry for the frontend service:

frontend:
  environment:
    - CHOKIDAR_USEPOLLING=true
  image: node:8
  volumes:
    - ../frontend:/app
  working_dir: /app
  command: "/bin/sh -c 'npm start'" # This runs `react-script start`
  external_links:
    - api
  ports:
    - "3008:3008"

Looking for somewhere to start debugging this as my google-fu failed.

Gowiem
  • 1,297
  • 17
  • 19
  • Shouldn't you be creating a build, not running `npm start`? I'm not super familiar with react, but I figured it you would want to [run the prod version](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build), not the dev. Also be sure to [set `NODE_ENV` to "production"](https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production). – zero298 Jul 03 '18 at 15:25
  • @zero298 I'm running this for a development server so that I can have other team members work within Docker locally. Production builds are not a problem AFAIK. – Gowiem Jul 03 '18 at 16:48
  • I'm having same issue. – amcdnl Jul 17 '18 at 16:02
  • @Gowiem did you ever discover the issue here? Having a similar problem with a dockerized react app - meanwhile a different app runs very quickly :( – C Bauer Jun 13 '22 at 19:04

0 Answers0