A sample React app and accompanying Dockerfile for publishing the built app to NGINX
Firstly make sure you fork this repository to your own GitHub account and the clone your forked version down to your local computer.
The application assumes you have Node and NPM installed.
It also assumes that you have the backend REST API running locally on port 3000.
To run the application locally you can run:
npm install
Followed by:
npm start
The application can be deployed as a Docker container.
In order to run in docker, firstly make sure the dependencies are pulled down
npm install
Then build the react app
npm run build
Then build the Docker image
docker build -t bookstore-frontend:1.0 .
Once the image has built you can start up the container by running:
docker run --rm -it -p 8080:80 bookstore-frontend:1.0
Then you should be able to open up your browser and head to http://localhost:8080/
Javascript packages can sometimes have vulnerabilities in them and if the versions (in the package.json) aren't updated then NPM highlights those vulnerabilities. For the purpose of this exercise you can ignore them, in production you would would to address them and update the versions.
This happens if you've forgot to run the npm run build
command before running the docker build....
command