Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   docs/config.md
	modified:   docs/deployment/localDeployment.md
  • Loading branch information
HadleyKing committed Jun 25, 2024
1 parent ce8a286 commit e5dd9ff
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 47 deletions.
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The HOSTNAME to be returnd in the `user_info` object. This is used by the BCO Po
The HUMAN_READABLE_HOSTNAME to be returnd in the `user_info` object. This is used by the BCO Portal for interacting with a specific instance of the BCO DB, and in the Swager Docs.

### PUBLIC_HOSTNAME
The PUBLIC_HOSTNAME to be returnd in the `user_info` object. This is used by the BCO Portal for interacting with a specific instance of the BCO DB, and in the Swager Docs. It is also utilized by the `activation_link`, `retrieve_bco`, `validate_bco_object_id` functions, as well as in the API tests.
The PUBLIC_HOSTNAME to be returnd in the `user_info` object. This is used by the BCO Portal for interacting with a specific instance of the BCO DB (i.e. to make requests), and in the Swager Docs. It is also utilized by the `activation_link`, `retrieve_bco`, `validate_bco_object_id` functions, as well as in the API tests.

### DATABASE
This value is used as the `"NAME"`in Django's [DATABASES](https://docs.djangoproject.com/en/5.0/ref/settings/#databases) object. The BCO DB is set up to use the default SQLITE. If you would like to have a database that is outside of the project folder and/or has a non-default name than you can provide an absolute path for the name value here.
Expand Down
130 changes: 84 additions & 46 deletions docs/deployment/localDeployment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# BCODB Local Deployment

## System Setup
### Requirements
- Python 3: [3.10.6 reccomended](https://www.python.org/downloads/release/python-3106/)
- [PyEnv](https://github.com/pyenv/pyenv) (optional but recommended fro Mac/Linux)

## Clone the repository
```
git clone https://github.com/biocompute-objects/bco_api
Expand All @@ -11,79 +16,112 @@ git clone https://github.com/biocompute-objects/bco_api
git switch [DESIRED BRANCH TAG]
```

## Enter the repository, create a virtual environment, and install the required packages
## Enter the repository
```
cd bco_api
```

## Create a virtual environment and install the required packages

### For Mac/Linux:

*skip this first step if you do not want to use `pyenv`*
```
pyenv local 3.10.6
```

```
python3 -m venv env
source env/bin/activate
python -m pip install -r requirements.txt
```

(You can use python3 if you’d like, but since you’re in the virtual environment you created python points to python3.10.6)
*If you are using `pyenv` and you’re in the virtual environment you created using just `python` points to python3.10.6*

### For Windows:
```
`cd server`
`python -m venv env`
`source env/Scripts/activate`
`pip install -r requirements.txt`
```

## Configure the DB settings using the `.secrets` file:

### OPTION 1: Generate the secrets file

In the project root copy the `.secrets.example` to `.secrets`

```
cp .secrets.example .secrets
```
#### Generate the DJANGO_KEY
Generate a 32-bytes long PSK key using the `openssl` command or `PowerShell` command.

##### Mac/Linux:
```
openssl rand -base64 32
```
##### Windows:
```
[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Minimum 0 -Maximum 256 }) -as [byte[]])
```

Use a text editor to open the `.secrets` file update the rest of the values with the required values. For specifics see the [configuration](/docs/config.md) documentation.

### OPTION 2: Use the `local_deployment.secrets` file
Fromt the project root:
```
cp admin_only/local_deployment.secrets .secrets
```

## Set up the databse
### Option #1: Use existing DB
This option will give you a working BCO DB with a couple of test users, existing BCOs, and some prefixes.
```
cp admin/db.sqlite3 .
python3 manage.py migrate
```


superusername: bco_api_user
password: testing123
````
---
### Option #2: Create a new DB with test data
Create a DB:
`python3 manage.py migrate`
Load the DB with test data:
## Modify the Config files:
Check/Edit the server.conf file
This is the main server configuration file for the BCO API. (most of these values will NOT need to be changed for local deployment)
`python manage.py loaddata tests/fixtures/testing_data.json`
vim bco_api/bco_api/server.conf
---
#### Run Server
`python3 manage.py runserver 8080`
Production and publishing flags NOTE: Valid values are True or False (note the capitalization).
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/`
DB Version
[VERSION]
version=22.01
Is this a publish-only server?
[PUBLISHONLY]
publishonly=False
Security settings: Create a key for an anonymous public user.
[KEYS]
anon=627626823549f787c3ec763ff687169206626149
Which host names do you want to associate with the server? Note: the local hostname (i.e. 127.0.0.1) should come at the end.
[HOSTNAMES]
prod_names=test.portal.biochemistry.gwu.edu,127.0.0.1
names=127.0.0.1:8000,127.0.0.1
Give the human-readable hostnames
[HRHOSTNAME]
hrnames=BCO Server (Default)
The public hostname of the server (i.e. the one to make requests to)
[PUBLICHOSTNAME]
prod_name=https://test.portal.biochemistry.gwu.edu
name=http://127.0.0.1:8000
Who gets to make requests?
[REQUESTS_FROM]
portal=https://test.portal.biochemistry.gwu.edu
local_development_portal=http://127.0.0.1:3000,http://localhost:3000
public=true
Namings: How do you want to name your objects?
[OBJECT_NAMING]
prod_root_uri=https://test.portal.biochemistry.gwu.edu
root_uri=http://127.0.0.1:8000
prod_uri_regex=root_uri/prefix_(\d+)/(\d+).(\d+)
uri_regex=root_uri/prefix_(\d+)/(\d+).(\d+)
**Requests ** Where are the request templates defined?
[REQUESTS]
folder=../api/request_definitions/
Where are the validation templates defined?
[VALIDATIONS]
folder=../api/validation_definitions/
Set up DB
cd bco_api/bco_api
Option #1: Use existing DB
Copy the dev db
Expand Down

0 comments on commit e5dd9ff

Please sign in to comment.