Git Product home page Git Product logo

react_docker_boilerplate's Introduction

Create-React-App 2.0 Dockerized

docker react splashpage image

In Development

> git clone

> sudo docker image build -t < container name here> .

> sudo docker container run -it -p 3000:3000 -p 35729:35729 -v $(pwd):/app < container name here >


Testing

> sudo docker container run -it -v $(pwd):/app < container name here >  test

Jest options

sudo docker container run -it -v $(pwd):/app < container name here > test --coverage
sudo docker container run -it -v $(pwd):/app < container name here > test --help

To Debug

> sudo docker container run -it -p 3000:3000 -p 35729:35729 -v $(pwd):/app --name mydebugging < container name here >

####################### open a  separate terminal ###################

> sudo docker exec -it mydebugging bash

######################################################################

> this will give you root access to your container terminal

To build

> sudo docker container run -it -v $(pwd):/app  < container name here >  build

Example Dockerfile

FROM node:8

ADD yarn.lock /yarn.lock
ADD package.json /package.json

ENV NODE_PATH=/node_modules
ENV PATH=$PATH:/node_modules/.bin
RUN yarn

WORKDIR /app
ADD . /app

EXPOSE 3000
EXPOSE 35729

ENTRYPOINT ["/bin/bash", "/app/run.sh"]
CMD ["start"]

Example shebang file

#!/usr/bin/env bash
set -eo pipefail

case $1 in
  start)
    # The '| cat' is to trick Node that this is an non-TTY terminal
    # then react-scripts won't clear the console.
    yarn start | cat
    ;;
  build)
    yarn build
    ;;
  test)
    yarn test $@
    ;;
  *)
    exec "$@"
    ;;
esac

Further development

Why not add a docker-compose file?

Credits:

Peter Bengtsson


This project was bootstrapped with Create React App and Docker

react_docker_boilerplate's People

Contributors

jwill9999 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.