Run the below command in the root directory of the project (Where the package.json resides).
- Change the working directory to the Server folder. cd Server
- Run the below maven command to build the boot project. mvn clean install -Dmaven.test.skip=true
- Run the below command to build a docker image for running the boot application. docker build -t spring/server .
- Below command deletes if already existing docker bridge network. docker network rm qna_net
- Below command creates a new docker bridge network. docker network create --subnet 172.25.0.0/16 qna_net
- Stop the mysql instance if already running. docker stop qna_mysql
- Remove the mysql container if already exist. docker rm qna_mysql
- Start the mysql instance. This will be hosting the application data store. docker run --name qna_mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=qnaapp --network=qna_net --ip=172.25.1.1 -d mysql:5.7.24
- Stop the boot container if already running. docker stop qna_boot
- Remove the boot container if already exists. docker rm qna_boot
- Start the boot docker using the below command. This will expose the boot server in the port 8080. docker run --name qna_boot -p 8080:8080 --network=qna_net -d spring/server
- Go one directory up. cd ..
- Install node dependencies. npm install
- Run production build. npm run build
- Build a docker image for the react app. docker build -t react/qnaapp .
- Stop the react app if already running. docker stop qnaapp
- Remove the react app container if already exists. docker rm qnaapp
- Finally run the react app docker. This exposes the React app in the port 80. docker run --name qnaapp -p 80:3000 -d react/qnaapp
Open the link http://localhost:80 in the browser to view the UI.