## ROR Installation Steps For OMNI 1. **Update the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories:** ```bash sudo apt update ``` 2. **Install necessary development tools and libraries required for building and running software:** ```bash sudo apt install -y git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev ``` 3. **Install `libcurl` and its development files:** ```bash sudo apt install libcurl4 libcurl4-openssl-dev ``` 4. **Install `libxml2` and its development files:** ```bash sudo apt install libxml2 libxml2-dev ``` 5. **Install ImageMagick and its development files:** ```bash sudo apt install imagemagick libmagickwand-dev ``` 6. **Install PostgreSQL and its development files:** ```bash sudo apt install postgresql libpq-dev ``` 7. **Start the PostgreSQL service:** ```bash sudo service postgresql start ``` 8. **Clone the `asdf` version manager repository to your home directory and checkout the specific branch `v0.11.3`:** ```bash git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3 ``` 9. **Add the `asdf` initialization script to your shell's configuration file (`~/.bashrc`), so it loads whenever you start a new shell session:** ```bash echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc ``` 10. **Reload your shell configuration to apply the changes made in the previous step:** ```bash source ~/.bashrc ``` 11. **Add the Ruby plugin to `asdf`, enabling `asdf` to manage Ruby versions:** ```bash asdf plugin-add ruby https://github.com/asdf-vm/asdf-ruby.git ``` 12. **Install Ruby version 2.7.4 using `asdf`:** ```bash asdf install ruby 2.7.4 ``` 13. **Clone the repository using SSH:** ```bash git clone git@github.com:PurpleplumTech/omni.git ``` 14. **(Alternative) Clone the repository using HTTPS:** ```bash git clone https://github.com/PurpleplumTech/omni.git ``` 15. **Change directory to the cloned repository:** ```bash cd omni/ ``` 16. **Check out the `staging` branch:** ```bash git checkout staging ``` 17. **Install the specific version of Bundler:** ```bash gem install bundler -v 2.4.22 ``` 18. **Install the required gems specified in the `Gemfile`:** ```bash bundle install ``` 19. **Install Redis , Start Redis Server and Check Redis Is Running or Not** ``` sudo apt install redis-server sudo service redis-server start redis-cli ping ``` 20. **Start Sidekiq** ``` bundle exec sidekiq -C config/sidekiq.yml ``` 21. **Postgres User Configuration** ``` # Switch to the PostgreSQL user sudo -i -u postgres # Access the PostgreSQL command line interface psql # Check if users have passwords set SELECT usename, passwd IS NOT NULL AS has_password FROM pg_shadow; # Optionally, change a user's password ALTER USER your_user WITH PASSWORD 'your_new_password'; # Exit the PostgreSQL command line interface \q ``` 22. **Create Database for the User** ``` # Switch to the PostgreSQL user sudo -i -u postgres # Create DB and link it to user createdb your_database -O your_user ``` 23. **Config In database.yml** ``` staging: <<: *default username: your_user password: your_password database: your_database port: 5432 ``` 24. **Initiate Database** ``` #Switch to project directory cd path_to_project_directory #Comment line 26 to 33 (batch related code) in sidekiq.rb #Load Database RAILS_ENV=staging bundle exec rake db:create db:schema:load db:migrate #UnComment line 26 to 33 (batch related code) in sidekiq.rb ``` 24. **Run The Server** ``` bundle exec rails s -e staging ``` These commands set up the necessary dependencies, clone the repository, and prepare the environment to run a Ruby on Rails application. ## Deployment Steps For OMNI ### Frontend Deployment Steps 1. **Build Your React Application Locally** Ensure your React application is built locally: ``` npm run build ``` 2. Securely Copy Build to the Server ``` scp -i ./omni_prod2.pem -r ./build/ ubuntu@52.221.173.152:/tmp ``` 3. Log Into the Server ``` ssh -i ./omni_prod2.pem ubuntu@52.221.173.152 ``` 4. Remove Existing Builds on the Server ``` rm -rf /tmp/build/ rm -rf /home/ubuntu/omni-webapp/build/ ``` 5. Copy the New Build to the Webapp Directory ``` cp -R /tmp/build/ /home/ubuntu/omni-webapp/ ``` ### Backend Deployment Steps 1. **Log Into the QA Server** First, log into your server using SSH: ``` ssh -i path_to_pem ubuntu@10.0.1.10 ``` 2. **Download The Repo From Git** ``` git clone https://github.com/PurpleplumTech/omni.git #Enter the directory cd omni #Install Dependencies and continue with Step 3. ``` 3. **Creating/Enter a screen session which allows you to keep the Rails server running even after disconnecting from SSH.** ``` #Check Screens List screen -list #Create New Screen no screens available in list. screen -S omni-server #If you want to enter exisiting screens. screen -rd omni-server #Stop the Server Ctrl + C #Take Latest Release From Github and replace the files using FileZilla. #Start the Server bundle exec rails s -e staging #Exit the Screen using Ctrl + A + D ``` 4. **Existing Frontend and Backend Paths in QA Server** ``` #Frontend Path /home/ubuntu/omni-webapp #Backend Path /home/ubuntu/omni-1.6/omni-1.6 ```