Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

teamxiv/growbot-help

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

GrowBot Installation

Prerequisites: Linux knowledge, a Virtual Machine running Debian 9.8 (stretch)

These instructions will walk you through:

  • Installing a text editor (vim) and version control system (git)
  • Installing a web server (nginx)
  • Setting up LetsEncrypt using certbot (for https, which is REQUIRED)
  • Building and deploying growbot-site
  • Setting up PostgreSQL
  • Building and deploying growbot-api

Prepare your virtual machine

These instructions assume your virtual machine is running Debian 9.

  1. Run $ apt update
  2. Install vim and git using $ apt install -y make vim git
  3. Fix vim by following the vim-sensible instructions

These instructions assume that you already have DNS settings fully configured.

Set up the web server

  1. Run $ apt install -y nginx
  2. Create the growbot nginx config file inside /etc/nginx/sites-available
  3. $ vim /etc/nginx/sites-available/growbot
  4. Paste the following content:
    server {
            listen 80;
    
            server_name growbot.tardis.ed.ac.uk;
    
            location / {
                    root /srv/growbot;
            }
    }
    
    server {
            listen 80;
    
            server_name api.growbot.tardis.ed.ac.uk;
    
            location / {
                    proxy_pass http://localhost:8080;
            }
    
            location /stream {
                    proxy_pass http://localhost:8080;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection $http_connection;
                    proxy_set_header Origin '';
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    }
  5. Create a folder to store the GrowBot website, mkdir /srv/growbot
  6. Create a test file containing <h1>Hello world</h1> at /srv/growbot/index.html
  7. Navigate to the enabled sites directory, cd /etc/nginx/sites-enabled
  8. Create a symlink to the growbot config, and rename it
  9. ln -s ../sites-available/growbot
  10. mv growbot growbot.conf
  11. Run $ nginx -s reload to reload the nginx configuration
  12. From your local machine, verify nginx is set up correctly by checking that curl growbot.tardis.ed.ac.uk displays <h1>Hello world!</h1>

Get the webapp online

  1. On your local machine, clone the website, git clone https://github.com/teamxiv/growbot-site.git
  2. $ cd growbot-site
  3. Install dependencies, npm install
  4. Create an optimised production build of the website, npm run build
  5. Upload the website using scp -r build/* remote:/srv/growbot/. Replace remote with the details of your remote server.

Set up the database

  1. On the remote machine, navigate to the source code directory (cd ~/growbot-api)
  2. Install PostgreSQL 11 (see these instructions)
  3. Edit /etc/postgresql/11/main/pg_hba.conf (the exact path may be different depending on the PostgreSQL version)
  4. Scroll down to the bottom
  5. Change the last column for "local" Unix domain socket connections to trust
  6. Change the last column for 127.0.0.1/32 to trust
  7. Change the last column for ::1/128 to trust
  8. Run service postgresql restart
  9. Create the default superuser account
  10. Switch to the postgres user, $ su postgres
  11. Create the root postgres superuser, $ createuser -s root
  12. Return back to the root user, hit ctrl+d
  13. Run psql postgres to open a postgres shell
  14. Execute create role growbot with login; to create a growbot "role" that is able to log in (so it's basically a user). This user has no password for convenience.
  15. Hit ctrl+d to leave the postgres shell
  16. Run make reset_schema to create a database, give our growbot user admin permissions on db growbot_dev, and load the database schema.

Deploy the API

  1. On your local machine, make sure Go is set up (you should have GOROOT and GOPATH set up appropriately).

    Don't have Go? Please follow the Go installation instructions.

    You should also add $GOPATH/bin to your $PATH. This is so that any self-built binaries (such as goimports) are easy to run.

  2. Already have Go set up? Make sure go version says you are running go 1.11 or later.

  3. Run go get github.com/teamxiv/growbot-api.

  4. Navigate to $GOPATH/src/github.com/teamxiv/growbot-api/cmd/growbot-api and run $ GOOS=linux go build to cross-compile a binary for your Linux VM.

  5. On the remote machine, run git clone https://github.com/teamxiv/growbot-api.git to clone growbot-api to ~/growbot-api.

  6. On your local machine, use scp growbot-api remote:growbot-api/ to send the cross-compiled binary to ~/growbot-api/growbot-api on the server named remote. Replace remote with the details of your remote server.

  7. On your remote machine, within ~/growbot-api, copy config.example.yml to config.yml

  8. In a screen session, run config=config.yml ./growbot-api, and your API should be deployed on api.growbot.tardis.ed.ac.uk via nginx!

Set up HTTPS

HTTPS is required for service workers and other web features (like camera access) to work correctly. You must set up HTTPS.

  1. Follow the installation instructions here: https://certbot.eff.org/lets-encrypt/debianstretch-nginx

Verify everything works

  1. In your browser, https://api.growbot.tardis.ed.ac.uk should show a HTML webpage containing exactly "404 page not found" in the source, and nothing else. Your browser should not complain about HTTPS.
  2. In your browser, https://growbot.tardis.ed.ac.uk should have the landing page. Click Register and test out registration. Your browser should not complain about HTTPS.
  3. If registration works correctly and you are logged in, everything is working correctly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published