Peiyan commited on
Commit
8948a11
·
unverified ·
1 Parent(s): b8440a4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +167 -1
README.md CHANGED
@@ -1 +1,167 @@
1
- # TrustworthyAI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TrustworthyAI
2
+
3
+ ## Local Dev Env Setup
4
+
5
+ - frontend
6
+ npm run start
7
+
8
+ - backend
9
+ python app.py
10
+
11
+ ## Setup in a new EC2 instance
12
+
13
+ Install nginx
14
+
15
+ ```
16
+ sudo apt install nginx
17
+ ```
18
+
19
+ Install apps
20
+
21
+ ```
22
+ sudo apt install certbot python3-certbot-nginx ranger docker.io
23
+ ```
24
+
25
+ Configure nginx
26
+
27
+ ```
28
+ sudo certbot --nginx -d guardai.io -d www.guardai.io
29
+ ```
30
+
31
+ Add this to the top of the nginx.conf on the EC2 instance
32
+
33
+ ```
34
+ limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s;
35
+ ```
36
+
37
+ Add proxy_pass` to both 80 and 443 blocks
38
+
39
+ ```
40
+ location / {
41
+ # Rate limits backend API calls
42
+ limit_req zone=mylimit;
43
+
44
+ proxy_pass http://127.0.0.1:3000/;
45
+ }
46
+ ```
47
+
48
+ See an example of final nginx configuration in`/deployment/default`.
49
+
50
+
51
+ Finally, restart nginx
52
+
53
+ ```
54
+ sudo systemctl restart nginx
55
+ ```
56
+
57
+
58
+
59
+ ## Build and run docker
60
+
61
+ Build:
62
+
63
+ ```bash
64
+ docker build --pull --rm -f Dockerfile -t trustworthy-ai .
65
+ ```
66
+
67
+ To run the docker image locally:
68
+
69
+ ```bash
70
+ docker run --rm -p 3000:80/tcp trustworthy-ai
71
+ ```
72
+
73
+ To push docker image to the repository:
74
+
75
+ ```bash
76
+ docker tag trustworthy-ai:latest paulcccccch/trustworthy-ai:latest
77
+ docker push paulcccccch/trustworthy-ai:latest
78
+ ```
79
+
80
+ To pull docker:
81
+
82
+ ```bash
83
+ docker login
84
+ docker run -p 3000:80 paulcccccch/trustworthy-ai:latest
85
+ ```
86
+
87
+ Clean up:
88
+
89
+ ```
90
+ sudo docker stop $(sudo docker ps -aq)
91
+ sudo docker rm $(sudo docker ps -aq)
92
+ sudo docker rmi $(sudo docker images -q)
93
+ ```
94
+
95
+
96
+ # Environment Setting:
97
+
98
+ ## Frontend:
99
+
100
+ * a. Download "Node.js". https://nodejs.org/en/download
101
+
102
+ * b. Once you have downloaded it successfully, run this code then you should be able to see the version number.
103
+
104
+ ```bash
105
+ node --version
106
+ ```
107
+
108
+ * c. Go to the 'frontend' directory and run this code and you will see a file called "node modules" in the frontend file.
109
+
110
+ ```bash
111
+ npm install
112
+ ```
113
+
114
+ * d. Run this code and a website should pop up.
115
+
116
+ ```bash
117
+ npm run start
118
+ ```
119
+
120
+ ## Backend:
121
+
122
+ * a. Download "Miniconda". https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html
123
+
124
+ * b. Once you have downloaded it successfully, run this code then you should be able to see the version number.
125
+
126
+ ```bash
127
+ conda --version
128
+ ```
129
+
130
+ * c. Go to the 'backend' directory.
131
+
132
+ * d. Create a virtual environment using this code:
133
+
134
+ ```bash
135
+ conda create --name 'name_of_environment'
136
+ ```
137
+
138
+ * e. Activate the environment you just created using this code:
139
+
140
+ ```bash
141
+ conda activate 'name_of_environment'
142
+ ```
143
+
144
+ You may check the existing environment using this code:
145
+
146
+
147
+ ```bash
148
+ conda env list
149
+ ```
150
+
151
+ * f. In the environment you just activated, install all the modules in requirements.txt
152
+
153
+ ```bash
154
+ pip install -r requirements.txt
155
+ ```
156
+
157
+ You can use this code to check what modules you already have in your environment:
158
+
159
+ ```bash
160
+ conda list
161
+ ```
162
+
163
+ * g. When all the modules are successfully downloaded, you should be able to run the whole project. Run this code to see if it works. (Be sure you are in the correct environment)
164
+
165
+ ```bash
166
+ python app.py
167
+ ```