BCO Portal Local Deployment

From BCOeditor Wiki
Jump to navigation Jump to search

Configuration

In order to work with BCO API locally on a Mac OS, please follow the following steps to set up:

BCO_API

  1. Clone the GitHub Repository
    1. Open Terminal, enter the following commands:
      1. git clone https://github.com/biocompute-objects/bco_api
      2. cd bco_api
  2. Switch to the latest release branch:
    1. git switch 22.10
  3. Enter the repository, create a virtual environment, and install the required packages:
    1. pyenv local 3.9.4 (Note: will show as pyenv: command not found if already installed)
    2. python3.9 -m venv env
    3. source env/bin/activate (activated virtual environment by showing (env) (base) MacBook-Pro-3:bco_api)
    4. python -m pip install -r requirements.txt (if installation failed, make sure you are in the correct path: /Users/Username/bco_api)
  4. Modify Configuration file
    1. Once in the virtual environment, make sure you are on the path:/Users/Username/bco_api
    2. Edit the server.conf file: vim bco_api/bco_api/server.conf
  5. Quick check to make sure the server can run
    1. cd bco_api/bco_api (Note after this command, should under path /Users/Username/bco_api/bco_api)
    2. Make migrations: python3.9 manage.py migrate
    3. If run successfully, should observe the following:
      Screen Shot 2022-10-04 at 15.05.22.png
  6. Create a super user for the API: python3.9 manage.py createsuperuser
    1. Follow the prompts
  7. python3.9 manage.py runserver 8000:
    Screen Shot 2022-10-04 at 15.15.54.png
    1. Once see the messages as shown in the figure above, go to http://localhost:8000/api/admin/ on the local browser to see if BCO API is set up successfully

UserDB

  1. Clone the GitHub Repository
    1. Open Terminal, enter the following commands:
      1. git clone https://github.com/biocompute-objects/userdb
      2. cd userdb/
  2. Switch to the desired branch: e.g. git switch 22.10
  3. Enter the repository, create a virtual environment, and install the required packages:
    1. pyenv local 3.9.4
    2. python3.9 -m venv env
    3. source env/bin/activate
    4. python -m pip install -r requirements.txt
  4. Modify the Config file: vim portalusers/settings.py
  5. Make migrations: python3.9 manage.py migrate
  6. Create a super user for the API: python3.9 manage.py createsuperuser (Note: this step can be skipped if a superuser is already created or not superuser account is not necessary)
  7. Run server: python3.9 manage.py runserver 8181
    1. If ran successfully, you should observe as shown in the following figure:
      Screen Shot 2022-10-05 at 14.20.20.png
    2. Once see the messages as shown in the figure above, go to http://localhost:8181/users/admin/ on the local browser to see if BCO API is set up successfully (Note: If it worked you should be able to login using the SuperUser credentials you created above)

Portal Deployment Instructions

  1. Clone the repository
    1. git clone https://github.com/biocompute-objects/portal
    2. cd portal/
  2. Switch to the desired branch: e.g. git switch 22.10
  3. Install packages with either of the following commands:
    1. npm install
    2. npm install --legacy-peer-deps
  4. Edit /portal/src/App.js line 87 based on your need :
    1. For local, sending = hostnames.local
    2. For the test site, sending = hostnames.test
    3. For the production site, sending = hostnames.production
  5. Start running: npm run start

Production Portal Deployment

The BCO API repository contains a top-level folder “admin_only” which contains service definitions for gunicorn and Django. Thus, we can first clone the repository, then perform a few administrative steps to start the API.

  1. Connect to 'go.vpn.gwu.edu/SMHS_BIOC' VPN first.
  2. Enter test/production server via: ssh USERNAME@test.portal.biochemistry.gwu.edu (for test server)/ssh USERNAME@portal.biochemistry.gwu.edu (for production server) (Note: /home and /etc are shared between the two servers)
  3. Backup and archive DB:
    1. cd /var/www/bcoeditor/db_backups
    2. cp ../bco_api/bco_api/db.sqlite3 db.sqlite3.bak.api.[TODAY'S DATE] (e.g. cp ../bco_api/bco_api/db.sqlite3 db.sqlite3.bak.api.22.10.25)
    3. cp ../userdb/db.sqlite3 db.sqlite3.bak.udb.[TODAY'S DATE]
    4. cp ../bco_api/bco_api/server.conf server.conf.bak.[TODAY'S DATE]
  4. Pull the repository
    1. cd /var/www/bcoeditor/bco_api
    2. git clone https://github.com/biocompute-objects/bco_api (if cloned already, step not needed)
  5. Enter the repository, create a virtual environment and install the required packages:
    1. First switch to the proper user account via su - bco_api_user (If need to use this account, please contact BCO team for password)
    2. Switch to the desired branch: git switch 22.11
    3. source env/bin/activate
    4. pip3.9 install -r requirements.txt
  6. Check the Configuration files:
    1. Edit the server.conf file: vim /var/www/bcoeditor/bco_api/bco_api/server.conf
      1. Change the version number to match the version you are modifying
  7. Make sure the server can run: cd /var/www/bcoeditor/bco_api/bco_api
  8. Make Migrations:
    1. python3.9 manage.py migrate
    2. python3.9 manage.py collectstatic
    3. python3.9 manage.py runserver 8000
    4. Go to https://test.portal.biochemistry.gwu.edu/api/admin/ to make changes
    5. Ctrl+C to exit the running server