Skip to content

Commit f127d19

Browse files
committed
Changes to be committed:
modified: docs/config.md modified: docs/deployment/localDeployment.md
1 parent 341a2e8 commit f127d19

File tree

2 files changed

+85
-47
lines changed

2 files changed

+85
-47
lines changed

docs/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The HOSTNAME to be returnd in the `user_info` object. This is used by the BCO Po
5656
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.
5757

5858
### PUBLIC_HOSTNAME
59-
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.
59+
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.
6060

6161
### DATABASE
6262
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.

docs/deployment/localDeployment.md

Lines changed: 84 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# BCODB Local Deployment
22

3+
## System Setup
4+
### Requirements
5+
- Python 3: [3.10.6 reccomended](https://www.python.org/downloads/release/python-3106/)
6+
- [PyEnv](https://github.com/pyenv/pyenv) (optional but recommended fro Mac/Linux)
7+
38
## Clone the repository
49
```
510
git clone https://github.com/biocompute-objects/bco_api
@@ -11,79 +16,112 @@ git clone https://github.com/biocompute-objects/bco_api
1116
git switch [DESIRED BRANCH TAG]
1217
```
1318

14-
## Enter the repository, create a virtual environment, and install the required packages
19+
## Enter the repository
1520
```
1621
cd bco_api
22+
```
23+
24+
## Create a virtual environment and install the required packages
1725

26+
### For Mac/Linux:
27+
28+
*skip this first step if you do not want to use `pyenv`*
29+
```
1830
pyenv local 3.10.6
31+
```
1932

33+
```
2034
python3 -m venv env
2135
2236
source env/bin/activate
2337
2438
python -m pip install -r requirements.txt
2539
```
2640

27-
(You can use python3 if you’d like, but since you’re in the virtual environment you created python points to python3.10.6)
41+
*If you are using `pyenv` and you’re in the virtual environment you created using just `python` points to python3.10.6*
42+
43+
### For Windows:
44+
```
45+
`cd server`
46+
`python -m venv env`
47+
`source env/Scripts/activate`
48+
`pip install -r requirements.txt`
49+
```
50+
51+
## Configure the DB settings using the `.secrets` file:
52+
53+
### OPTION 1: Generate the secrets file
54+
55+
In the project root copy the `.secrets.example` to `.secrets`
56+
57+
```
58+
cp .secrets.example .secrets
59+
```
60+
#### Generate the DJANGO_KEY
61+
Generate a 32-bytes long PSK key using the `openssl` command or `PowerShell` command.
62+
63+
##### Mac/Linux:
64+
```
65+
openssl rand -base64 32
66+
```
67+
##### Windows:
68+
```
69+
[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Minimum 0 -Maximum 256 }) -as [byte[]])
70+
```
71+
72+
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.
73+
74+
### OPTION 2: Use the `local_deployment.secrets` file
75+
Fromt the project root:
76+
```
77+
cp admin_only/local_deployment.secrets .secrets
78+
```
79+
80+
## Set up the databse
81+
### Option #1: Use existing DB
82+
This option will give you a working BCO DB with a couple of test users, existing BCOs, and some prefixes.
83+
```
84+
cp admin/db.sqlite3 .
85+
python3 manage.py migrate
86+
```
87+
88+
89+
superusername: bco_api_user
90+
password: testing123
91+
````
92+
93+
---
94+
### Option #2: Create a new DB with test data
95+
Create a DB:
96+
97+
`python3 manage.py migrate`
98+
99+
Load the DB with test data:
28100
29-
## Modify the Config files:
30-
Check/Edit the server.conf file
31-
This is the main server configuration file for the BCO API. (most of these values will NOT need to be changed for local deployment)
101+
`python manage.py loaddata tests/fixtures/testing_data.json`
32102
33-
vim bco_api/bco_api/server.conf
103+
---
104+
#### Run Server
105+
`python3 manage.py runserver 8080`
34106
35-
Production and publishing flags NOTE: Valid values are True or False (note the capitalization).
107+
Make sure API is accessible via web browser. EX:
108+
````
109+
http://localhost:8080/users/admin/
110+
````
111+
If it worked you should be able to see the API Documentation site at:
36112
113+
`http://localhost:8080/users/docs/`
37114
38-
DB Version
39115
40-
[VERSION]
41-
version=22.01
42-
Is this a publish-only server?
43116
44-
[PUBLISHONLY]
45-
publishonly=False
46-
Security settings: Create a key for an anonymous public user.
47117
48-
[KEYS]
49-
anon=627626823549f787c3ec763ff687169206626149
50-
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.
51118
52-
[HOSTNAMES]
53-
prod_names=test.portal.biochemistry.gwu.edu,127.0.0.1
54-
names=127.0.0.1:8000,127.0.0.1
55-
Give the human-readable hostnames
56119
57-
[HRHOSTNAME]
58-
hrnames=BCO Server (Default)
59-
The public hostname of the server (i.e. the one to make requests to)
60120
61-
[PUBLICHOSTNAME]
62-
prod_name=https://test.portal.biochemistry.gwu.edu
63-
name=http://127.0.0.1:8000
64-
Who gets to make requests?
65121
66-
[REQUESTS_FROM]
67-
portal=https://test.portal.biochemistry.gwu.edu
68-
local_development_portal=http://127.0.0.1:3000,http://localhost:3000
69-
public=true
70-
Namings: How do you want to name your objects?
71122
72-
[OBJECT_NAMING]
73-
prod_root_uri=https://test.portal.biochemistry.gwu.edu
74-
root_uri=http://127.0.0.1:8000
75-
prod_uri_regex=root_uri/prefix_(\d+)/(\d+).(\d+)
76-
uri_regex=root_uri/prefix_(\d+)/(\d+).(\d+)
77-
**Requests ** Where are the request templates defined?
78123
79-
[REQUESTS]
80-
folder=../api/request_definitions/
81-
Where are the validation templates defined?
82124
83-
[VALIDATIONS]
84-
folder=../api/validation_definitions/
85-
Set up DB
86-
cd bco_api/bco_api
87125
88126
Option #1: Use existing DB
89127
Copy the dev db

0 commit comments

Comments
 (0)