From eedf578aafaacad501733fdf816086f8c3eca9a0 Mon Sep 17 00:00:00 2001 From: mrxmamun Date: Sun, 27 Oct 2019 18:51:31 +0600 Subject: [PATCH] dockerize react app and update readme --- README.md | 5 ++- docker/README.md | 46 ++++++++++++++++++++ {python => docker/python}/Dockerfile | 2 +- docker/react/Dockerfile | 16 +++++++ system/supervisor/{frontend.MD => README.MD} | 0 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 docker/README.md rename {python => docker/python}/Dockerfile (91%) create mode 100644 docker/react/Dockerfile rename system/supervisor/{frontend.MD => README.MD} (100%) diff --git a/README.md b/README.md index 57edb2a..3147ddb 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - [Datetime (Unix , RealTime and Formatted Datetime)](js/datetime.js) ## React JS - [React ENV Create](react-js/env.md) +- [Dockerize React App](docker/react/Dockerfile) - [React Socket Connection](react-js/Socket.js) - [Exportable API Endpoint](react-js/api/ApiHelper.js) - [Example API Helper Routes ](react-js/api/ExampleApi.js) @@ -35,7 +36,7 @@ ## Python - [Flask Socket Connection](python/flask_socket.py) - [Flask Socket Connection with Pubsub to listen subscription messages](python/flask_pubsub.py) -- [Dockerize Flask App](python/Dockerfile) +- [Dockerize Flask App](docker/python/Dockerfile) - [Python Open-CV Video Recording](python/video_record.py) - [Find Router Connected Device Ip List](python/router_ip_address.py) - [Google Cloud Pub/Sub Publishing/subscription messages and subscriptions list](python/pubsub.py) @@ -62,7 +63,7 @@ - [Set Go Path](go/go-path-set.go) ## System -- [Supervisor Installation and Procedure](system/supervisor/frontend.MD) +- [Supervisor Installation and Procedure](system/supervisor/README.MD) ## Other - [Install Protobuf 3 on Ubuntu](https://gist.github.com/mrxmamun/c3afc8e9318135d5f79177ff528655a4) diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..a5f0177 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,46 @@ +## Installation +- Install [Docker](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04) +- Make a file name Dockerfile ```touch Dockerfile``` + +### Flask App [Dockerfile](/docker/python/Dockerfile) +```sh +FROM python:3.8-alpine + +RUN apk add --no-cache python3-dev \ + && pip3 install --upgrade pip + +WORKDIR /src + +COPY . . + +RUN pip install -r requirements.txt + +EXPOSE 5000 + +ENTRYPOINT ["python3"] + +CMD ["app.py"] +``` +### React App [Dockerfile](/docker/python/Dockerfile) +```sh +# base image +FROM node:12.13.0-alpine + +# set working directory +WORKDIR /src + +# add `/app/node_modules/.bin` to $PATH +ENV PATH /src/node_modules/.bin:$PATH + +# install and cache app dependencies +COPY . . +RUN npm install --silent +RUN npm install react-scripts@3.1.1 -g --silent + +# start app +CMD ["npm", "start"] +``` +### Instruction +- `docker build -t name .` +- `docker run --name name -d -p port:port name` or +- `docker run --name name -d -p port:port --network host name` diff --git a/python/Dockerfile b/docker/python/Dockerfile similarity index 91% rename from python/Dockerfile rename to docker/python/Dockerfile index 629d207..afd4355 100644 --- a/python/Dockerfile +++ b/docker/python/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-alpine +FROM python:3.8-alpine RUN apk add --no-cache python3-dev \ && pip3 install --upgrade pip diff --git a/docker/react/Dockerfile b/docker/react/Dockerfile new file mode 100644 index 0000000..1ad1dfa --- /dev/null +++ b/docker/react/Dockerfile @@ -0,0 +1,16 @@ +# base image +FROM node:12.13.0-alpine + +# set working directory +WORKDIR /src + +# add `/app/node_modules/.bin` to $PATH +ENV PATH /src/node_modules/.bin:$PATH + +# install and cache app dependencies +COPY . . +RUN npm install --silent +RUN npm install react-scripts@3.1.1 -g --silent + +# start app +CMD ["npm", "start"] \ No newline at end of file diff --git a/system/supervisor/frontend.MD b/system/supervisor/README.MD similarity index 100% rename from system/supervisor/frontend.MD rename to system/supervisor/README.MD