Skip to content

Latest commit

 

History

History
94 lines (81 loc) · 2.71 KB

README.md

File metadata and controls

94 lines (81 loc) · 2.71 KB

Production Setup

Systemd is an easy way to manage running this web application on a linux system. Another option is running with docker, for those who prefer it.

Quick setup of MongoDb

It's better to follow other, updated instructions, but if you just need to do it quickly:

  1. Install mongo:
    sudo apt update
    sudo apt install -y mongodb
  2. Check mongo status. This should show running and you can connect and see the mongo version:
    sudo systemctl status mongodb
    mongo --eval 'db.runCommand({ connectionStatus: 1 })'
  3. Create a user:
    # Connect to your mongo database
    mongo
    # Create user
    db.createUser({ user:'someuser', pwd:'somepassword', roles:[ { role:'readWrite', db:'boardfarm' } ] })

That's it, press CTRL-D to exit.

Setup with Systemd

I recommend running with systemd. These instructions are for Ubuntu.

  1. Modify the file sys/bfapi.service to contain your settings for your mongodb:
    Environment="MONGO_USER=yourmongouser"
    Environment="MONGO_PASS=yourmongopass"
    Environment="MONGO_SERVER=localhost"
    
  2. Also change the username and directory path:
    User=youruser
    ExecStart=/path/to/boardfarm_server_api/index.js
    
  3. Copy the service file:
    sudo cp bfapi.service /lib/systemd/system/
  4. Reload:
    sudo systemctl daemon-reload
  5. Start the app:
    sudo systemctl start bfapi
  6. You should be able to visit your web app at http://localhost:5001/api

Extra commands:

# Check status
sudo systemctl status bfapi
# See log files
sudo journalctl -u bfapi
# Eanble to automatically run on boot:
sudo systemctl enable bfapi
# Stop the app
sudo systemctl stop bfapi
# Restart the app
sudo systemctl restart bfapi

Setup with Docker

Another way to run this app is with docker. If you choose to use docker, here's how to set that up.

  1. Start and setup your mongodb docker container (unless you have it setup somewhere else)
    docker run -d -e MONGO_INITDB_ROOT_USERNAME=$adminuser \
        -e MONGO_INITDB_ROOT_PASSWORD=$adminpass -p 27017:27017 \
        --name mongodb mongo:latest
    docker exec -it mongodb mongo -u $adminuser -p $adminpass \
         --eval "db.createUser({ user:'$bftuser', pwd:'$bftpass', roles:[ { role:'readWrite', db:'boardfarm' } ] })"
  2. Build the docker container for this project:
    docker build -t bft:server_api .
  3. Start the docker container:
    docker run -e MONGO_USER=$bftuser \
        -e MONGO_PASS=$bftpass -e MONGO_SERVER=$mongodbserver \
        -p 5001:5001 bft:server_api
  4. You should be able to visit your web app at http://localhost:5001/api