Running React app inside a Docker container – Peter Jausovec – Medium

Running React app inside a Docker container  #react #docker #nodejs #reactjs

  • Running React app inside a Docker containerHere are simple steps on how to create an empty React app, create a production build of the app and run it inside of a Docker container.Start with creating an new React app:Install create-react-app:npm install create-react-app –global2.
  • Create a sample React app:create-react-app react-docker-app3.
  • Run the app to make sure all is good:yarn startLet’s add a Dockerfile with the following contents to the root folder:Lines 1–4 are the first stage of the build, where we copy all source code to the container and execute yarn run build to create a production build.Lines 6–10 are…
  • Finally, we run serve to run the app.To build the image, you can run docker build -t react-docker-app and run it with docker run -dit -p 8080:80 react-docker-app .
  • At this point, you can navigate to http://localhost:8080 and see the app running there.

Here are simple steps on how to create an empty React app, create a production build of the app and run it inside of a Docker container. Lines 1–4 are the first stage of the build, where we copy all…

Running React app inside a Docker containerHere are simple steps on how to create an empty React app, create a production build of the app and run it inside of a Docker container.Start with creating an new React app:Install create-react-app:npm install create-react-app –global2. Create a sample React app:create-react-app react-docker-app3. Run the app to make sure all is good:yarn startLet’s add a Dockerfile with the following contents to the root folder:Lines 1–4 are the first stage of the build, where we copy all source code to the container and execute yarn run build to create a production build.Lines 6–10 are the second stage of the build where we install serve and on line 9 we copy the output from the first stage (from folder /app/build to current folder (/app)). Finally, we run serve to run the app.To build the image, you can run docker build -t react-docker-app and run it with docker run -dit -p 8080:80 react-docker-app .At this point, you can navigate to http://localhost:8080 and see the app running there.

Running React app inside a Docker container – Peter Jausovec – Medium