2017-11-01 10:56:13 -06:00
|
|
|
# How to install FarmBot Web API on a Fresh Ubuntu 17 machine.
|
|
|
|
|
|
|
|
# Remove old (possibly broke) docker versions
|
|
|
|
sudo apt-get remove docker docker-engine docker.io
|
|
|
|
|
|
|
|
# Install docker
|
2018-03-09 02:08:43 -07:00
|
|
|
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common rake --yes
|
2017-11-01 10:56:13 -06:00
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
|
|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" --yes
|
|
|
|
sudo apt-get update --yes
|
|
|
|
sudo apt-get install docker-ce --yes
|
|
|
|
sudo docker run hello-world # Should run!
|
|
|
|
|
|
|
|
# Install RVM
|
|
|
|
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
|
|
|
|
curl -sSL https://get.rvm.io | bash
|
|
|
|
source /usr/local/rvm/scripts/rvm
|
2018-04-12 14:02:51 -06:00
|
|
|
rvm install "ruby-2.5.1"
|
2017-11-01 10:56:13 -06:00
|
|
|
cd .
|
2018-04-12 14:02:51 -06:00
|
|
|
rvm --default use 2.5.1
|
2017-11-01 10:56:13 -06:00
|
|
|
# LOG OUT AND LOG BACK IN NOW.
|
|
|
|
|
|
|
|
# Image Magick
|
|
|
|
sudo apt-get install imagemagick --yes
|
|
|
|
|
|
|
|
|
|
|
|
# Install Node
|
|
|
|
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
|
|
|
|
sudo apt-get install -y nodejs --yes
|
|
|
|
|
|
|
|
# Install Yarn
|
|
|
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
|
|
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
|
|
|
sudo apt-get update && sudo apt-get install yarn
|
|
|
|
|
|
|
|
# Install database deps
|
|
|
|
sudo apt-get install libpq-dev postgresql-contrib --yes
|
|
|
|
|
|
|
|
# Install FarmBot Web App
|
2018-03-27 06:00:46 -06:00
|
|
|
git clone https://github.com/FarmBot/Farmbot-Web-App --depth=10 --branch=master
|
2017-11-01 10:56:13 -06:00
|
|
|
cd Farmbot-Web-App
|
|
|
|
gem install bundler
|
|
|
|
npm install yarn
|
|
|
|
bundle install
|
|
|
|
yarn install
|
|
|
|
cp config/database.example.yml config/database.yml
|
|
|
|
|
|
|
|
# == This is a very important step!!! ==
|
|
|
|
#
|
|
|
|
# Open `config/application.yml` in a text editor and change all the values.
|
|
|
|
#
|
|
|
|
# == Nothing will work if you skip this step!!! ==
|
2018-03-09 10:50:54 -07:00
|
|
|
# Don't know which editor to use?
|
|
|
|
# Use micro! `snap install micro --classic`
|
|
|
|
cp config/application.example.yml config/application.yml
|
2017-11-01 10:56:13 -06:00
|
|
|
# READ THE FILE AND CHANGE THE VALUES ^
|
|
|
|
sudo -u postgres psql
|
2018-04-06 13:26:55 -06:00
|
|
|
rake keys:generate
|
2017-11-01 10:56:13 -06:00
|
|
|
# Run this:
|
|
|
|
# CREATE USER "your_username_here" WITH SUPERUSER;
|
|
|
|
# \q
|
|
|
|
rake db:create:all db:migrate db:seed
|
|
|
|
RAILS_ENV=test rake db:create db:migrate && rspec spec
|
|
|
|
npm run test
|
|
|
|
|
2018-01-23 09:16:47 -07:00
|
|
|
# INSTALLATION IS NOW COMPLETE =================================================
|
|
|
|
|
2017-11-01 10:56:13 -06:00
|
|
|
|
2018-01-23 09:16:47 -07:00
|
|
|
# You may run the commands below every time you wish to start the server:
|
|
|
|
# The commands before this were only one-off commands for installation.
|
2017-11-01 10:56:13 -06:00
|
|
|
# Run the web server (new tab, SAME DIRECTORY)
|
2018-01-23 09:16:47 -07:00
|
|
|
# Don't worry about the "MQTT server is unreachable" messages yet-
|
|
|
|
# we still need to start MQTT (next).
|
2017-11-01 10:56:13 -06:00
|
|
|
rails api:start
|
|
|
|
|
2018-01-23 09:16:47 -07:00
|
|
|
# Run MQTT (new tab, SAME DIRECTORY)
|
|
|
|
rails mqtt:start
|
2018-05-10 10:59:50 -06:00
|
|
|
|
|
|
|
# NEXT STEP IS OPTIONAL. DO THIS IF YOU WANT TO USE PORT 80 INSTEAD OF 3000.
|
|
|
|
|
|
|
|
# This is a quick alternative to running rails as root / sudo.
|
|
|
|
|
|
|
|
# Step 1: Install `socat`
|
|
|
|
sudo apt-get install socat
|
|
|
|
# Step 2: Forward port 80 to port 3000
|
|
|
|
sudo socat TCP-LISTEN:80,fork TCP:localhost:3000
|
|
|
|
|
|
|
|
# Other options for routing traffic to port 80 include:
|
|
|
|
# * Using `iptables`
|
|
|
|
# * Configuring NGinx as a reverse proxy.
|
|
|
|
# The options above are intended for advanced users.
|
|
|
|
# Our ability to provide support to individual users for these use cases is
|
|
|
|
# limited
|