Skip to content

Deployment

Sam Ping edited this page Apr 21, 2021 · 3 revisions

Deployment

Sledge is currently in the process of being deployed on AWS EC2. As of now, the dev server is hosted on a t2.micro instance with 8GB of storage space.

  1. Create EC2 instance and connect to it. Keep the .pem key somewhere safe!
    1. Create instance:
      • OS: Ubuntu 20.04 LTS x64
      • Instance Type: t2.micro (vCPUs: 1, Memory: 1GiB)
      • Storage Space: 8GB SSD
      • Tags (optional):
        • Name: sledge-dev/prod
        • env: dev/prod
    2. Inbound rules:
      • Allow HTTP and HTTPS. Expose port 5000 (which the server uses).
  2. Update and install dependencies:
    1. sudo apt update # updates repositories
    2. sudo apt install git # installs Git
    3. curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    4. sudo apt-get install -y nodejs # installs NodeJS and NPM
    5. By now, you should have Git, NodeJS, and NPM installed.
    6. Now you can install PM2 with npm i pm2 -g. This will be used later in deploying the Express server. If you get an error, try running the same command using sudo.
    7. Install MongoDB (instructions taken from https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/):
      1. wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - # should return OK
      2. echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
      3. sudo apt-get update
      4. sudo apt-get install -y mongodb-org # installs MongoDB
    8. Now MongoDB should be installed. To start the service, run sudo systemctl start mongod.
  3. Now deploy the server:
    1. Clone the Sledge repository with git clone https://github.com/HackRU/sledge.git # clones over HTTPS, may have to be updated
    2. cd sledge/server # go into the server directory
    3. npm i # installs Sledge server dependencies
    4. Now if you run node server.js, you'll see that the server is up and running. However, if you close the terminal, the server will also stop running. Thus, we will be using PM2 (which we installed in the dependencies section) to keep the server running.
    5. If you haven't already, close the current Node.js process with CTRL-C. Now run the Express server using PM2 by running pm2 start server.js, and you're good to go!
Clone this wiki locally