Farmbot_web_app for vmware

I don’t really like using docker, is there a non-docker version that can be used in a virtual machine?

I am not used to using docker, so I built the host myself based on the farmbot development materials. Here is a breakdown of the building process.

I referred to the following materials:

https://github.com/FarmBot/Farmbot-Web-App/
https://github.com/FarmBot/Farmbot-Web-App/blob/staging/ubuntu_example.sh
https://github.com/FarmBot/Farmbot-Web-App/blob/staging/docker-compose.yml

Based on the steps of ubuntu_example.sh, the contents of docker-compose.yml execution are combined, as well as my own observations of using my.farm.bot. At present, the version of the build has been basically controlled. My actual official version is express xl 1.1 version, and the version used to test the host is genesis v1.2 ramps version.


0. install ubuntu22.04 in vmware

Memory: 4G
Hard disk: 40G


1. Install redis

sudo apt update
sudo apt install redis-server

sudo systemctl status redis

#Enable Redis service to start at boot:
sudo systemctl enable redis

#Use the Redis client to connect to the server to ensure that it is working properly:
redis-cli

#At the Redis prompt, enter the ping command. You should receive PONG as a response, which indicates that Redis is working properly.

2. Install postgresql

Account: postgres, Password: postgres123qwe

#Install PostgreSQL:
sudo apt install postgresql postgresql-contrib

#Start PostgreSQL service:
#PostgreSQL service should start automatically after installation. You can check its status with the following command:
sudo systemctl status postgresql

#Enable PostgreSQL service at boot:
sudo systemctl enable postgresql

2.1.1 Add alias

#Add /etc/hosts
127.0.0.1 db

2.1.2 Change password

#change password
sudo -i -u postgres
\password postgres

PGPASSWORD=postgres123qwe psql -h db -U postgres -d postgres

# set var to .env
POSTGRES_PASSWORD=postgres123qwe


2.1.3 Add user record
#Connect to PostgreSQL

PGPASSWORD=postgres123qwe psql -h db -U postgres

View all databases
\l
or
SELECT datname FROM pg_database;

#Connect to database
\c farmbot_development

#View all tables
\dt

#Add user records
script/python_user.sh

#Clear records
TRUNCATE TABLE public.users;

#View records
SELECT * FROM public.users;

#Exit
\q

3. Install ruby:3.1.6

3.1 Install rvm

#Update package index and install dependencies:
sudo apt install -y curl gpg build-essential

#Import GPG key and install rvm:

\curl -sSL https://rvm.io/mpapis.asc | gpg --import -
\curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
\curl -sSL https://get.rvm.io | bash -s stable

#Load rvm script:
#Add the following to your shell configuration file (such as ~/.bashrc or ~/.zshrc)

source ~/.rvm/scripts/rvm

source ~/.bashrc # or source ~/.zshrc

3.2 Need to set 'Run command as login shell'

( https://rvm.io/integration/gnome-terminal )
https://rvm.io/rubies/default
https://rvm.io/integration/gnome-terminal

3.3 Install ruby ​​

# install 

rvm install 3.1.6
rvm use 3.1.6 --default

# check version 

ruby -v


4. Install RabbitMQ

# version 

RabbitMQ 3.9.13
Erlang 24.2.1

4.1 Install elang Erlang 24.2.1

#Update package index:

sudo apt update

#Install Erlang:
sudo apt install -y erlang

#Verify Erlang installation
#Once the installation is complete, you can verify that Erlang was installed successfully with the following command:
erl

#This will start the Erlang Shell and you should see output similar to the following:

4.2 Install RabbitMQ RabbitMQ 3.9.13

#Update the package index:

sudo apt update
sudo apt install -y rabbitmq-server

#Start the RabbitMQ service:
#The RabbitMQ service should start automatically after installation, you can check its status with the following command:

sudo systemctl status rabbitmq-server
sudo systemctl stop rabbitmq-server
sudo systemctl start rabbitmq-server

#Enable RabbitMQ management plugin:

sudo rabbitmq-plugins enable --offline \
rabbitmq_auth_backend_http \
rabbitmq_management \
rabbitmq_mqtt \
rabbitmq_auth_backend_cache \
rabbitmq_web_mqtt

#Create an administrator user:

sudo rabbitmqctl add_user admin admin123
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

4.3 Access the RabbitMQ management interface:

#Open a browser and visit http://localhost:15672. Log in using the newly created admin user and the corresponding password.

4.4 Verify the installation

#You can verify that the RabbitMQ service is running properly by running the following command:

sudo rabbitmqctl status

#With these steps, you should be able to install RabbitMQ on Ubuntu

4.5 Change port 15675 to 3002

# because farmbot use 3002 replace 15675 
# and some var for RabbitMQ 
# 192.168.0.199 is my host ip

sudo vim /etc/rabbitmq/rabbitmq.conf
web_mqtt.tcp.port = 3002
auth_backends.1 = cache
auth_cache.cache_ttl = 600000
auth_cache.cached_backend = http
auth_http.http_method = post
auth_http.resource_path = http://192.168.0.199:3000/api/rmq/resource
auth_http.topic_path = http://192.168.0.199:3000/api/rmq/topic
auth_http.user_path = http://192.168.0.199:3000/api/rmq/user
auth_http.vhost_path = http://192.168.0.199:3000/api/rmq/vhost
default_user = admin
default_user_tags.administrator = true
default_user_tags.management = true
default_pass = admin123
mqtt.allow_anonymous = false

5. Install Farmbot-Web-App

#Version installation need for farmbot

node20.x 
npm 10.x 
parcel 2.x

5.1.1 Install nvm

# real installed version : 

"@types/node": "20.14.2",
"npm": "10.8.1",
"parcel": "2.12.0",

# wget -O xxx Set local file name
wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh -O nvm-install.sh

# Install
bash nvm-install.sh ​

# Execute `source ~/.bashrc` or `source ~/.zshrc` (depending on your shell) to make nvm effective
source ~/.bashrc

5.1.2 Install node and npm

# install nodejs

nvm install 20.14.0

# nmp install will install other from package.json

5.1.3 Test

# check vesion 

nodejs -v
npm -v
parcel --version

# real version for me 

node v20.14.0 (npm v10.7.0)

5.1.4 Configure Gemfile to use .env variables

# use .env , add to Gemfile

gem 'dotenv-rails', groups: [:development, :test]


5. 2 Install Farmbot-Web-App

cd ~

git clone https://github.com/FarmBot/Farmbot-Web-App --depth=5 --branch=main

cd ~/Farmbot-Web-App

# ⚠ SKIP THIS STEP IF UPGRADING!
cp example.env .env

# change some thing for .env 

# Install the correct version of bundler for the project
sudo gem install bundler

# Install application specific Ruby dependencies
bundle install

# Install application specific Javascript deps
npm install

# Create a database in PostgreSQL
bundle exec rails db:create db:migrate

# Generate a set of *.pem files for data encryption
#SKIP THIS STEP IF UPGRADING
sudo chmod 777 -R docker_configs docker_volumes
rake keys:generate

# Build the UI assets via ParcelJS
rake assets:precompile

# At this point, setup is complete. Content should be visible at ===============

5.3 Start and execute threads

#Start web

bundle exec passenger start

#parcel
bundle exec rake api:serve_assets

#typescript
node_modules/typescript/bin/tsc -w --noEmit

#delayed_job
bundle exec rake jobs:work

#log_digests
bundle exec rake api:log_digest

#rabbit_jobs
bundle exec rails r lib/rabbit_workers.rb

5.4 Visit the website

# http://localhost:3000/.

my .env

# ░██████░░███████░░█████░░░██████░░
# ░██░░░░░░░░██░░░░██░░░██░░██░░░██░  READ EVERYTHING BEFORE USING.
# ░██████░░░░██░░░░██░░░██░░██████░░  SEE NOTES BELOW
# ░░░░░██░░░░██░░░░██░░░██░░██░░░░░░
# ░██████░░░░██░░░░░████░░░░██░░░░░░
# You will hit issues if any of these are set to the wrong value.
# Please read each line of this file before starting the server.
#
# When you are done, save this file as `.env` at the root of the Farmbot-Web-App
# directory.
#
#  Again, PLEASE READ ALL ENTRIES. This is the most important setup step.
# =============================================================================
#
# Where is your MQTT server running? 99% of setups will use the same value
# found in API_HOST. Heroku users will not use the same value.
# Use a REAL, PUBLIC IP ADDRESS if you are controlling real bots.
MQTT_HOST=192.168.0.199
# Set the max pool size for Passenger.
# Only needed if using Heroku. FarmBot, Inc. uses Heroku. Self hosters do not.
MAX_POOL_SIZE=2
# If your server is on a domain (eg=my-own-farmbot.com), put it here.
# DONT USE `localhost`.
# DONT USE `127.0.0.1`.
# DONT USE `0.0.0.0`.
# Use a real ip or domain name.
API_HOST=192.168.0.199
# 3000 for local development. 443 is using SSL. You will need `sudo` to use PORT
# 80 on most systems.
API_PORT=3000
# Every server needs to set this. This is the password to the entire database.
# NOTE: Must be less than 100 characters long.
POSTGRES_PASSWORD=postgres123qwe
# MUST REPLACE. MUST BE A VERY RANDOM VALUE.
# 128 CHARACTERS LONG, HEXADECIMAL STRING (0-9, A-F)
# DEVISE_SECRET=Used for devise. Generate a new value using `openssl rand -hex 64`.
DEVISE_SECRET=bcbdcae2764720f8761ac27051c3d867e2557d3d51250e92d37048431068ea50ae85547b2f6b5665cb2d7788eeca6a51c4acfbfac9675879ac354c7f99639fdf
# Every server has a superuser.
# Set this to something SECURE.
ADMIN_PASSWORD=admin123
# Secret key used by Rails.
# Generate a new value using `openssl rand -hex 64`
SECRET_KEY_BASE=86055d42cfcf3486cb2bbc0d3a4ef88c826b07c52155a6048ae87d4cd41689d95834679fbaba0c7f667b29fe8598b81c7fae91d15aa5559c96395c443930cf54
# Set this to production in most cases.
# Setting this line to production will disable debug backtraces.
# Please delete this line if you are submitting a bug report, as production mode
# will not give detailed crash reports.
#RAILS_ENV=production
# Set this if you don't want to deal with email verification of new users.
# (self hosted users)
NO_EMAILS=TRUE
# If you wish to opt out of https:// (we wish you wouldn't), you can
# delete this line. Be aware that by not using SSL, users will transmit their
# passwords without encryption, making it very easy for attackers to see
# user passwords. Consider buying a domain and using a free certificate from
# Let's Encrypt.
#FORCE_SSL=Remove this if not using HTTPS://

#  MOST USERS SHOULD DELETE THE REST OF THIS FILE.
#  Continue reading if you:
#   * work at FarmBot, Inc.
#   * need email notification support
#   * pay for managed database / file hosting (Google Cloud)
#   * use the test suite to write new features
# If running a FarmBot setup for personal use or none of the above apply, you
# can safely delete the rest of this file.

# Only relevant if you use Heroku or pay a 3rd party vendor for Redis hosting.
# Most users can delete this.
# If your Heroku Redis vendor uses a custom `REDIS_URL` ENV var such as
# `REDISTOGO_URL`, set the value here. If you  delete this line, the app will
# default to `REDIS_URL`.
#WHERE_IS_REDIS_URL=REDISTOGO_URL # Just an example. Change or delete.
# Delete this if you  don't use 3rd party Redis hosting. See WHERE_IS_REDIS_URL
REDIS_URL=redis://localhost:6379/0

# For email delivery. Who is your email host?
SMTP_HOST=smtp.sendgrid.net
# Optional with default of 587
SMTP_PORT=587
# FarmBot, Inc. uses SendGrid to send emails.
# Delete these if you aren't a send grid customer.
SENDGRID_PASSWORD=Used by FarmBot, Inc
SENDGRID_USERNAME=Used by FarmBot, Inc
# If you're using other SMTP server (like Gmail) use this.
#SMTP_USERNAME=email@gmail.com
#SMTP_PASSWORD=password

# Used by people who pay for managed database hosting.
# Most users should delete this.
#DATABASE_USERNAME=postgres
#DATABASE_PASSWORD=postgres123qwe
#DATABASE_NAME=myapp_production
#DATABASE_HOST=db
#DATABASE_URL=postgres://postgres:n@localhost:5432/db_name
# Google Cloud Storage API Bucket for image data.
# Deleting this will save to disk.
# Most self hosting users will want to delete this.
# GCS_BUCKET=GOOGLE_CLOUD_STORAGE_BUCKET_NAME_FOR_IMAGE_FILES
# Google Cloud Storage ID for image data.
# Deleting this will save images to disk.
# Most self hosting users will want to delete this.
# GCS_ID=GOOGLE_CLOUD_STORAGE='interop' id
# Most self hosting users will want to delete this.
# GCS_KEY=GOOGLE_CLOUD_STORAGE='interop' key
# GCS_PROJECT=
# GOOGLE_CLOUD_KEYFILE_JSON=
# Can be deleted unless you are a Rollbar customer.
# ROLLBAR_ACCESS_TOKEN=____
# ROLLBAR_CLIENT_TOKEN=____
# ROLLBAR_ENV=
# Can be deleted unless you are using codecov.
# CODECOV_TOKEN=
# This can be set to anything.
# Most users can just delete it.
# This is used for people writing modifications to the software, mostly.
# DOCS=Set this to any value if you want to generate API docs after running tests
# Most self hosting users will want to delete this.
#HEROKU_SLUG_COMMIT=This is set by Heroku, used by Frontend to show current version.
# If you are a software developer and you wish to run integration tests, set the
# ENV below to true.
# Most users will not want this enabled.
#RUN_CAPYBARA=true
# Self hosting users can delete this line.
# If you are not using the standard MQTT broker (eg=you use a 3rd party
# MQTT vendor), you will need to change this line.
# MQTT_WS=ws://192.168.0.199:3002/ws/mqtt
# If you are using a shared RabbitMQ server and need to use a VHost other than
# /, change this ENV var.
# MQTT_VHOST=/

# If you run a server with multiple domain names (HINT=You probably don't),
# you can list the names here. This is used by FarmBot employees so that they
# can securely host the same server on multiple domain names
#     ex=my.farm.bot, my.farmbot.io
EXTRA_DOMAINS=192.168.0.199
# Some hosts (Eg=FarmBot, Inc.) run the RabbitMQ management API on a
# non-standard host.
# Include the protocol! (http vs. https)
# DELETE THIS LINE if you are a self-hosted user.
#RABBIT_MGMT_URL=http://delete_this_line.com
# defaults to `CLOUDAMQP_URL`
WHERE_IS_CLOUDAMQP_URL=
CLOUDAMQP_URL=
RABBITMQ_URL=
# Allow only certain users on the server. If the user's email domain is not
# on the list of trusted domains, they can not use the server.
# The example below only allows users with `@farmbot.io` or `@farm.bot` emails
# to use the server.
# DELETE THIS LINE IF YOU RUN A PUBLIC SERVER.
# TRUSTED_DOMAINS=farmbot.io,farm.bot
# Self hosting users can safely delete this (a new key will be created).
# This key is used to exchange secrets between bots and MQTT servers (important
# if you don't use SSL)
# SERVER WONT WORK IF YOU FORGET TO DELETE THIS EXAMPLE TEXT BELOW.
# ADD A REAL RSA_KEY OR DELETE THIS LINE!!
#RSA_KEY=Change this! Keys look like `-----BEGIN RSA .........`
# Prevents JS/CSS build system from cleaning out old assets on start.
# This speed up boot time by one minute, but may put you at risk of
# loading stale versions of the application.
NO_CLEAN=true
# FarmBot uses DataDog for log analytics and for assessing overall system health.
# Do not add this key if you do not use DataDog on your server.
DATADOG_CLIENT_TOKEN=??
# Comma separated list of emails that wish to receive a daily
# report of new FarmBot installations (not new users, but
# actual FarmBot installations).
CUSTOMER_SUPPORT_SUBSCRIBERS=1043931@qq.com
# URL to send user-generated feedback to.
FEEDBACK_WEBHOOK_URL=http://localhost:3000/change_this
# Email address of a "publisher account" that is used to
# publish shared sequences via `rake sequences:publish <id>`
AUTHORIZED_PUBLISHER=foo@bar.com
# URL to send release info to.
RELEASE_WEBHOOK_URL=
# OpenAI API key. Delete this line if you don't have one.
OPENAI_API_KEY=
# OpenAI API sampling temperature. Optional. Float between 0 and 2.
# Defaults to 1, use a lower value for less random output.
OPENAI_API_TEMPERATURE=
# OpenAI model name for Lua code generation requests.
OPENAI_MODEL_LUA=
# OpenAI model name for other requests.
OPENAI_MODEL_OTHER=

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.