This README provides instructions to deploy the BioCompute Portal Locally
Before starting, ensure you have the following installed:
- For HTTPS access:
git clone https://github.com/biocompute-objects/portal_userdb
- For SSH access*(RECCOMENDED)*:
git@github.com:biocompute-objects/portal_userdb.git
Then
cd portal_userdb/
Make sure you are on the desired branch:
git switch <BRANCH NAME>
(24.06.27 Reccomended)
Stash Any Local Changes
git stash git stash drop
cd portal_userdb/client/
cd portal_userdb/client/
Install Node packages via Node Package Manager (NPM)
npm install
Set up the environment file
cp .env.example .env
Then you will have to add values for the following:
REACT_APP_USERDB_URL=http://localhost:8080/users/
REACT_APP_BCOAPI_URL=http://127.0.0.1:8000/api/
REACT_APP_GOOGLE_CLIENT_ID=******************************************
REACT_APP_ORCID_URL=https://sandbox.orcid.org
REACT_APP_ORCID_CLIENT_ID==******************************************
REACT_APP_ORCID_CLIENT_SECRET==******************************************
REACT_APP_SERVER_URL=http://localhost:3000
REACT_APP_BCOAPI_TOKEN=*****************
Verify you are still in the right directory and install client dependencies
cd client
npm install
npm run start
This will open http://localhost:3000/
in your default web browser if everything went according to plan. See the troubleshooting tips if not.
This terminal will be serving the React frontend.
Open a new terminal and return to the project root
cd PATH/TO/PROJECT/portal_userdb
cd server
pyenv local 3.10.6
(optional)
python3 -m venv env
source env/bin/activate
pip3.9 install -r requirements.txt
cd server
python -m venv env
source env/Scripts/activate
pip install -r requirements.txt
pyenv local (if pyenv was installed)
pyenv versions (if pyenv was installed)
pyenv local 3.10.6 (if pyenv was installed)
source ~/.zshrc (or specified terminal)
pip install --upgrade pip
pip install -r requirements.txt
-
Copy the
.secrets.example
to.secrets
cp .secrets.example .secrets
-
On linux (or MAC) generate a 32-bytes long PSK key using the openssl command for the
DJANO_KEY
:
openssl rand -base64 32
- On Windows, generate a 32-bytes long PSK key using the PowerShell command for the
DJANGO_KEY
:
[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Minimum 0 -Maximum 256 }) -as [byte[]])
- Update the
.secrets
file with the required keys:
[GOOGLE_KEYS]
DJANGO_GOOGLE_OAUTH2_CLIENT_ID=<your-client-id-here>
DJANGO_GOOGLE_OAUTH2_CLIENT_SECRET=<your-client-secret-here>
[DJANGO_KEYS]
SECRET_KEY=<your-Django-secret-key--here>
[ORCID_KEYS]
DJANGO_ORCID_OAUTH2_CLIENT_URL=http://localhost:3000
DJANGO_ORCID_OAUTH2_CLIENT_ID=<your-orcid-id-here>
DJANGO_ORCID_OAUTH2_CLIENT_SECRET=<your-orcid-secret-here>
DJANGO_ORCID_OAUTH2_URL=https://sandbox.orcid.org
[SERVER]
SERVER_VERSION=24.04
SERVER_URL=http://localhost:3000
SERVER_DB_URL=http://127.0.0.1:8000
#DATABASE=/Users/hadley_king/Data/userdb/db.sqlite3
DATABASE=db.sqlite3
cp admin/db.sqlite3 .
python3 manage.py migrate
superusername: bco_api_user
password: testing123
Create a DB:
python3 manage.py migrate
Load the DB with test data:
python manage.py loaddata config/fixtures/local_data/json
python3 manage.py runserver 8080
Make sure API is accessible via web browser. EX:
http://localhost:8080/users/admin/
If it worked you should be able to see the API Documentation site at:
http://localhost:8080/users/docs/
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 (only necessary to clone once since we can use the shell scripts in the repository after the initial cloning to administer the application), then we can perform a few administrative steps to start the API.
git clone https://github.com/biocompute-objects/bco_api
cd bco_api
Make sure you are on the desired branch (Check for latest branch):
git switch 24.06.27
Enter the repository, create a virtual environment, and install the required packages
pyenv local 3.10.6
python3 -m venv env
source env/bin/activate
python -m pip install -r requirements.txt
(You can use python3.9 if you’d like, but since you’re in the virtual environment you created python points to python3.9)
This is the main server configuration file for the BCO API. (most of these values will NOT need to be changed for local deployment)
nano .secrets
**Add Given Fields and Contact Admin for Keys
[DJANGO_KEYS]
SECRET_KEY=***************
ANON_KEY=******************************
[SERVER]
PRODUCTION=False
DEBUG=True
ALLOWED_HOSTS=*
SERVER_VERSION=24.06.13
HOSTNAME=127.0.0.1:8000
HUMAN_READABLE_HOSTNAME=DEV BCODB
PUBLIC_HOSTNAME=http://127.0.0.1:8000
SERVER_URL=http://localhost:3000
DATABASE=db.sqlite3
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
cd bco_api/bco_api
Copy the dev db
cp ../admin_only/db.sqlite3.dev db.sqlite3
superusername: bco_api_user
password: testing123
Make Migrations
python3 manage.py migrate
Make Migrations
python3 manage.py migrate
Create a super user for the API:
python3 manage.py createsuperuser
Then follow the prompts
Start the server
python3 manage.py runserver 8000
Make sure API is accessible via web browser.
[YOU WEB HOST HERE]/api/admin/
EX: http://localhost:8000/api/admin/
If it worked you should be able to login using the SuperUser credentials you created above
Log in with the superuser credentials you created or imported
If you copied over the existing dbs you should be able to log in with any of the crednetials listed in /portal_userdb/server/admin/users.tsv
Otherwise you will have to register a new user.