/fun-with-friends

CRUD Registry App. Node/React/Mongo. Containerized and available on Dockerhub. Testing on TravisCI.

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

An artifact registry for IT Project (COMP30022).

TravisCI Docker-Image Docker-Layers GitHub Issues Activity Codacy Codacy Coverage

Stack

Fun With Friends is built using the MERN stack, consisting of a React frontend served by a NodeJS backend running Express and connected to a MongoDB database.

Build Pipeline

  1. New pull requests trigger TravisCI to deploy a new worker
  2. The worker pulls the repo, installs package dependencies, runs unit and integration tests and builds the React client
  3. On success, the worker then builds a Docker container of the React client and Express server and pushes it to DockerHub
  4. On the production server running Ubuntu, Watchtower receives a notification that there is a new latest container. It then fetches the new latest container and gracefully runs the new container while stopping the old container.

Development

  1. Navigate to the server directory with cd server
  2. Execute npm run dev to start both the React client and Express server in development mode allowing instant refreshes. The React client listens on port 3000 and the Express server listens on port 8080. Any changes in the code will be displayed after a page refresh.

Production

  1. From the root directory, navigate to the React client's directory with cd client
  2. Update the React client's packages with npm install
  3. Build the React client with npm run build
  4. From the root directory, navigate to the Express server's directory with cd server
  5. Set the environment variable NODE_ENV to production with export NODE_ENV = production
  6. Start the express server with npm start. The Express server listens on port 8080 and serves the static React client content that was built.

Docker

  1. To build the docker container of the server, use docker image build -t <name>:<tag> . while in the root directory
  2. To run the docker container, use docker run -p 80:8080 -e NODE_ENV=production <name>:<tag> after building

Contributors