Skip to content

Commit

Permalink
Dockerize React App - Create Docker Image
Browse files Browse the repository at this point in the history
  • Loading branch information
repodevs committed Oct 15, 2017
1 parent de433d7 commit 6d3eb94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ WORKDIR /usr/src/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH

# add environment variables
ARG REACT_APP_USERS_SERVICE_URL
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
ENV REACT_APP_USERS_SERVICE_URL $REACT_APP_USERS_SERVICE_URL

# install and cache app dependencies
ADD package.json /usr/src/app/package.json
RUN npm install --silent
RUN npm install [email protected] -g --silent
RUN npm install pushstate-server -g --silent

# add app
ADD . /usr/src/app

# build react app
RUN npm run build

# start app
CMD ["npm", "start"]
CMD ["pushstate-server", "build"]

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,28 @@ $ python manage.py seed_db
$ python manage.py runserver -p 5555
```

## Other Command

To Build Docker image React App:
```bash
$ docker build -t "test" ./ --build-arg NODE_ENV=development --build-arg REACT_APP_USERS_SERVICE_URL=http://FLASK_SERVER_URL
```
To run the `test` image:
```bash
$ docker run -d -p 9000:9000 test
```
To view container's environment:
```bash
$ docker exec CONTAINER_ID bash -c 'env'
```
To stop and remove container:
```bash
$ docker stop CONTAINER_ID
$ docker rm CONTAINER_ID
```
To remove the image:
```bash
$ docker rmi test
```


0 comments on commit 6d3eb94

Please sign in to comment.