Giter VIP home page Giter VIP logo

cra_docker's Introduction

This project was bootstrapped with Create React App.

Available Scripts

  • build a image

docker build -t sample:dev .

  • show images

docker images

  • run container

docker run \ -it \ --rm \ -v ${PWD}:/app \ -v /app/node_modules \ -p 3000:3000 \ -e CHOKIDAR_USEPOLLING=true \ sample:dev

Exp

The docker run command creates and runs a new container instance from the image we just created.

  • it starts the container in interactive mode. Why is this necessary? As of version 3.4.1, react-scripts exits after start-up (unless CI mode is specified) which will cause the container to exit. Thus the need for interactive mode.

  • --rm removes the container and volumes after the container exits.

  • -v ${PWD}:/app mounts the code into the container at “/app”.

  • {PWD} may not work on Windows.

Since we want to use the container version of the “node_modules” folder, we configured another volume: -v /app/node_modules. You should now be able to remove the - local “node_modules” flavor.

  • -p 3000:3000 exposes port 3000 to other Docker containers on the same network (for inter-container communication) and port 3001 to the host.

  • -e CHOKIDAR_USEPOLLING=true enables a polling mechanism via chokidar (which wraps fs.watch, fs.watchFile, and fsevents) so that hot-reloading will work.

MORE

docker help

cra_docker's People

Contributors

3ndrius avatar

Watchers

 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.