Skip to content

Instantly share code, notes, and snippets.

@vinicius5581
Created April 2, 2022 16:38
Show Gist options
  • Save vinicius5581/0798352a29c92d86ed18dec8b11592a2 to your computer and use it in GitHub Desktop.
Save vinicius5581/0798352a29c92d86ed18dec8b11592a2 to your computer and use it in GitHub Desktop.

Getting Started

  1. Install dependencies
npm install
  1. Create a config.js file with Github token to link to Atlier API. If you do not have access, reference the server code to create the backened to supply the data.

  2. Start the server

npm start
  1. Bundle with Webpack
npm run dev

Tests and coverage

Test only the changes from last commit

npm run test

Test all the files

npm run test:all

Generate coverage to change from last commit

npm run coverage

Generate coverage to all files

npm run coverage:all

To see coverage report, go to: http://localhost:52330/coverage/lcov-report/

To see coverage of the main branch on gitHub go to: https://sensational-sycamore.github.io/sycamore/coverage/lcov-report

Deployment

  1. Create a EC2 instance running Ubuntu(linux).

  2. Set EC2 security groups rules(add inboud rule for HTTP).

  3. Save the pem key somewhere secure in your computer and give it read permition.

chmod 400 aws-keypair.pem
  1. Connect to your EC2 via SSH.
ssh -i "aws-keypair.pem" [email protected]
  1. Install EC2 dependencies.
sudo apt-get update && sudo apt-get upgrade -y

# download node make sure your version on your local matches the version you get
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -

# install node
sudo apt-get install -y nodejs

# set up port fowarding You might need to make a change
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

sudo apt-get install gcc g++ make

sudo apt-get install git
  1. Setup environment variables
export GITHUB_TOKEN=xxxxxxxxxxxx

You can check if the variable was set with:

printenv
  1. Clone code base into EC2.
git clone https://github.com/sensational-sycamore/sycamore.git
  1. Install project dependencies.
cd sycamore
npm install
  1. Build frontend
npm run dev

Stop the watch with crtl + c

  1. Test if project runs
npm run start

Stop the server with ctrl + c

  1. PM2 PM2 cheatsheet
sudo npm install pm2 -g
pm2 start server/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment