Skip to content

stefan22/react-docker-dev-environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepScan grade   GitHub last commit   npm version   JavaScript Style Guide

React-docker-dev-environment 🚀

React dev environment with docker

Requires: React,Node,Npm,Docker,Docker-cli
TEST:   🥯
  • Create a ui dir with a test file in it.
RUN:
>$ docker run -it --rm -v ${PWD}/ui:/app node:<VERSION>-alpine sh

It downloads a node alpine image (docker registry) then exec into the container and access the shell.


TEST:
  • CD into container app, and locate test.txt file.
  • If found there,then remove ui folder
  • Mount React app here: npx create-react-app ui
Build docker image
  • Create Dockerfile
  • Building image off node alpine: docker build -t reactdock
  • reactdock is now a new image built off the alpine 'base' image, and it can be used to run a react application.

Mounted app container



RUN Docker image
  • Flags: it (interactive), rm (remove afterwards), v (mounting), p (ports:3001 local to env and 3000 local to container), e(env polling changes)

docker run -it --rm -v ${PWD}/ui:/app -p 3001:3000 -e CHOKIDAR_USEPOLLING=true <imageName>

Mounted reactdock container


Docker-compose option to build image/ run container

  • Create docker-compose file
  • Remove any running docker images, add exec flags to compose file
  • Type: docker-compose up --build

Running this repository

  • Clone repository
  • Read top/bottom if needed
  • Only type this in terminal: docker-compose up --build to create image/ run container.

💯