Farmbot-Web-App/ubuntu_example.sh

78 lines
3.1 KiB
Bash
Raw Normal View History

# How to install FarmBot Web API on a Fresh Ubuntu 18.04.1 LTS Machine
2017-11-01 10:56:13 -06:00
2019-01-24 07:07:11 -07:00
# IMPORTANT NOTE: Resources are limited and Farmbot, inc. cannot provide
# longterm support to self-hosted users. For users who have never administered a
# Ruby on Rails applications, this presents an extremely high risk of data loss.
#
# IF YOU ARE NOT A DEVELOPER you are highly encouraged to use the my.farm.bot
# servers. Self hosted documentation is provided with the assumption that you
# have experience with Ruby/Javascript development. Self-hosting a Farmbot
# server is not a simple task.
2017-11-01 10:56:13 -06:00
# Remove old (possibly broke) docker versions
sudo apt-get remove docker docker-engine docker.io
# Install docker
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common --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 docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
2017-11-01 10:56:13 -06:00
# Install FarmBot Web App
# ⚠ SKIP THIS STEP IF UPGRADING!
git clone https://github.com/FarmBot/Farmbot-Web-App --depth=10 --branch=master
2018-10-04 12:29:09 -06:00
cd Farmbot-Web-App
2017-11-01 10:56:13 -06:00
# == This is a very important step!!! ==
#
2018-10-04 13:20:57 -06:00
# Open `.env` in a text editor and change all the values.
2017-11-01 10:56:13 -06:00
#
# == Nothing will work if you skip this step!!! ==
2018-05-27 12:41:18 -06:00
snap install micro --classic # Don't like `micro`? vim, nano, etc are fine, too.
cp example.env .env # ⚠ SKIP THIS STEP IF UPGRADING!
micro .env # ⚠ SKIP THIS STEP IF UPGRADING!
# ^ This is the most important step
2018-10-14 14:40:17 -06:00
# READ NOTE ABOVE. Very important!
# Install application specific Ruby dependencies
sudo docker-compose run web bundle install
# Install application specific Javascript deps
sudo docker-compose run web npm install
# Create a database in PostgreSQL
2018-10-19 12:12:13 -06:00
sudo docker-compose run web bundle exec rails db:create db:migrate
# Generate a set of *.pem files for data encryption
sudo docker-compose run web rake keys:generate # ⚠ SKIP THIS STEP IF UPGRADING!
2019-02-01 07:56:03 -07:00
# Build the UI assets via ParcelJS
sudo docker-compose run web npm run build
# Run the server! ٩(^‿^)۶
sudo docker-compose up
2019-01-24 07:07:11 -07:00
# ===
# To update to later versions of FarmBot,
# shut down the server, create a database backup
# and run commands below.
git pull https://github.com/FarmBot/Farmbot-Web-App.git master
sudo docker-compose run web bundle install
sudo docker-compose run web npm install
sudo docker-compose run web rails db:migrate
# ===
# At this point, setup is complete. Content should be visible at ===============
# http://YOUR_HOST:3000/.
# You can optionally verify installation by running unit tests.
2018-05-27 12:41:18 -06:00
# Create the database for the app to use:
sudo docker-compose run -e RAILS_ENV=test web bundle exec rails db:setup
# Run the tests in the "test" RAILS_ENV:
sudo docker-compose run -e RAILS_ENV=test web rspec spec
# Run user-interface unit tests:
sudo docker-compose run web npm run test