Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Last active July 28, 2017 04:15
Show Gist options
  • Select an option

  • Save cesarmiquel/55a59c5239b043c6de66b13eb3eda200 to your computer and use it in GitHub Desktop.

Select an option

Save cesarmiquel/55a59c5239b043c6de66b13eb3eda200 to your computer and use it in GitHub Desktop.
Trying out React

Generate an Docker image with Node and Create React App installed. For this edit a file called Dockerfile with the following content:

FROM node:6-alpine

# Install create-react-app
RUN npm install -g create-react-app

WORKDIR /src

CMD [ "node" ]

Build the image with the following command:

$ docker build -t react-app .

Generate a blank app with:

$ mkdir app
$ docker run -it --rm -v "$PWD"/app:/usr/src/app -w /usr/src react-app create-react-app app

To run the app:

$ docker run -it --rm --expose 3000 -v "$PWD"/app:/usr/src/app -w /usr/src/app react-app yarn start

The app will launch. You can access it on whatever IP Docker is running on (usually 172.x.x.x). On my machine I need to connect to:

Since the Docker runs as root you should change ownership of the app/ directory (from there on up) to your user:

$ sudo chown -R `id -u`:`id -g` app

Where [user] and [group]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment