Giter VIP home page Giter VIP logo

react-docker's Introduction

Build Status

Dev vs Test vs Prod

TEST :

npm run test

CMD diff Dev vs Prod Dev Server Prod Server

Dev

  • Dockerfile : Dockerfile.dev
  • use docker-compose.yml
  • entrypoint command : npm run start
  • use react development-server
  • use docker volumes option to mapping :
    • local dir with the container dir
    • Foldernode_modules/ is bookmark-ed, to use exising node_modules/ folder inside container, instead of replacing it with the reference/mapping to local dir volume.
      • Foldernode_modules/ is not bookmark-ed Without Bookmark Volume
      • Foldernode_modules/ is bookmark-ed prefered With Bookmark Volume
  • url : http://localhost:3000/

Build Docker Image

Manually using docker-cli to build the docker image.

docker build -f Dockerfile.dev .

Using docker-compose to Create Container With Build Option

Create Container

docker-compose up
Create container with build option

If there is a changes to Dockerfile.dev or new sevices added to docker-composer.yml file.

docker-compose up --build

Run The Test

List the services :

docker ps -a

Then get the container id of the web-app. Then run script below. Replace [CONTAINER-ID] with the actual container id value.

docker exec -it [CONTAINER-ID] npm run test

run the test with coverage, and immediate exit with 0, after finished. To avoid the watch mode, never ending process.

docker run harryosmar/react-docker npm run test -- --coverage

Prod

  • Dockerfile : Dockerfile
  • do not use docker-compose.yml
  • entrypoint command : npm run build
  • use nginx server
  • only container public/ folder
  • Has 2 phases :
    • build phase : install npm dependencies, then build the files for production usage inside
    • run phase : copy build files from /app/build folder in build phase, then create the web server/nginx 2 phases
  • url : http://localhost:8080/

Build

docker build .

Create Container

docker run -p 8080:80 [CONTAINER-ID]

react-docker's People

Contributors

harryosmar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.